Hi everyone who know about VB,i have a assignment to do,i have to save,delete,search and update.. i am not sure about my code in the button update ... this is my code ,wouls you mind show me my mistake ,thank you so much.
vb
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim line As String
Dim fields() As String
Dim objSR As StreamReader
objSR = New StreamReader(m_FILEPATH)
'create a temp
Dim objSW As New StreamWriter(Application.StartupPath & _
"\Temp1.txt", True)
line = objSR.ReadLine
Do Until (line Is Nothing)
fields = line.Split(Convert.ToChar(","))
If (fields(0) = txtUserID.Text) Then
Else
objSW.WriteLine(fields(0) & "," & fields(1) & "," & fields(2))
End If
line = objSR.ReadLine
Loop
objSR.Close()
MessageBox.Show("Do you want to update the file?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
MessageBox.Show("Please enter your new data.", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
If (fields(0) = txtUserID.Text) Then
My.Computer.FileSystem.MoveFile(m_FILEPATH, CStr(fields(0) = txtUserID.Text))
objSR.Close()
MessageBox.Show("Your file already update.", " Delete Record", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
My.Computer.FileSystem.RenameFile(Application.StartupPath & _
"\temp1.txt", "user.txt")
Else
End If
End Sub