Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

VB 6.0 .dat help


ghost's Avatar
0 0

Right, I am due to hand in a project tomorrow in school.

However, I'm not too proficient with VB 6.0 and am having some troubles in completing it.

I've created a membership administration system… storing records in a data (.dat) file. The record data is added correctly to the .dat file and is being displayed fine into a list box.

However, I now need to add an option to delete a members data from the data file.

My project includes 5 forms and 1 module. Forms: 1.) Add a member 2.) Display all members 3.) Delete a member 4.) Menu to navigate through all of the above 5.) A splash screen

Module: 1.) Stores char length for data such as surnames etc.

Here is the code I have strung together which doesn't work :-


Private Sub cmddel_Click()
    Dim uniqueID As String
    Dim response As Integer
    Dim DataToDisplay As String
    On Error GoTo finish
    uniqueID = InputBox("Enter the member ID you wish to remove", "Delete member")
    
    
    lstmembers.Clear
    
    Open FilenameID For Random As #1 Len = Len(member)
    Seek #1, uniqueID
    Get #1, uniqueID, member
    
    'check if employee has not been deleted already
    
    If member.Present = True Then
       With member
DataToDisplay = .forename & "" & .surname & "" & .dob & "" & .house & "" & .street & "" & .town & "" & .postcode
                lstdisplay.AddItem DataToDisplay
End With
        
        
    response = MsgBox("Do you want to delete this member?", vbYesNo + vbInformation, "Delete Record")
        If response = vbYes Then
                'change boolean to false to indicate 'deleted'
            member.Present = False
            Put #1, uniqueID, member 'put record back in file
                Else
                    MsgBox "Back to main screen", , "Return to Main screen"
                    Close #1
                    Exit Sub
                End If
            Else
                MsgBox "Record does not exist", vbOKOnly + vbCritical, "Illegal Record Number"
            End If
        Close #1
        Exit Sub
finish:
MsgBox "No Record number entered", vbCritical, "Error in Record Number"
End Sub

Rather than posting all of my forms/buttons code etc, if you think you could help me then I will send you my project or the necessary forms.

And before you start bitching about the level of programming VB is, I don't have the choice of any other. It was VB Or MS ACCESS…. exactly.

Thanks for any responses

Flash.