1 year ago

#284987

test-img

Ziyad Abdul sattar

Update button not updating values that have been loaded into a textbox by a file

My code is made up of saving records to files and reading those records, the structure of my files are made up of modules, this code is from visual basic 2010. I'm having a hard time understanding why this particular part of my code doesn't work, I'm new to coding and this website so if you have any other questions please let me know.

 Private Sub btnupdatestaff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnupdatestaff.Click
        Dim NumberOfrecords As Integer
        Dim OneStaff As Staff
        Dim StaffFile As String
        StaffFile = "Staff.txt"
 
        If OneStaff.StaffID = searchstaffid.Text Then
            OneStaff.fname = fname.Text
            OneStaff.StaffID = txtstaffid.Text
            OneStaff.phonenum = phonenum.Text
            OneStaff.email = email.Text
            OneStaff.username = username.Text
            OneStaff.password = password.Text
            OneStaff.deleted = "N"
            FileOpen(1, StaffFile, OpenMode.Random, , , Len(OneStaff)) 'open the staff file for one staff'
            NumberOfrecords = LOF(1) / Len(OneStaff) 'work out the number of records in the file'
            FilePut(1, OneStaff, NumberOfrecords + 1) 'add the new staff to the end of the file'
            FileClose(1) 'close the file'
        Else

            MsgBox("", MsgBoxStyle.Information, "Error")

        End If

    End Sub
                

vb.net

vb.net-2010

0 Answers

Your Answer

Accepted video resources