Private Sub txtName_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtName.LostFocus
Try
Dim filereader As New IO.StreamReader("C:\Users\hanna\Desktop\SCHOOL 2018 (MAY)\VB Assignment\VB Assignment\My Project\StudentDetails.csv")
While filereader.EndOfStream = False
Details = filereader.ReadLine.Split(",")
If txtName.Text.ToUpper() = Details(0).ToUpper() Then
Match = True
End If
End While
Catch
Match = True
MessageBox.Show("Student has already been added to the system", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try
Match = False
End Sub
尽管可以工作,但我在表单上键入的任何内容都会出现在消息框中。我的意图是仅在单击表单上的“保存”按钮后显示消息框。我希望您能指出问题所在。