Can someone pls help me with this problem
first I create a class which have a string property
Finally I run a for loop and compare the stdName property with textbox.text
and I add watch:
Why the compare return 1
(
first I create a class which have a string property
then I open a text file and put into array of that classProperty stdName() As String
Dim arrStudent() As Students
Dim allstdinfo As New IO.StreamReader(dlgOpenStudentsFile.FileName)
Do Until (allstdinfo.Peek() = -1)
Dim strAllstdinfo As String = allstdinfo.ReadLine()
Dim arrStudentLine() As String
arrStudentLine = strAllstdinfo.Split(New String() {"||"}, StringSplitOptions.RemoveEmptyEntries)
ReDim Preserve arrStudent(counter)
Dim singlestudent As New Students
singlestudent.stdName = arrStudentLine(0)
singlestudent.stdClass = arrStudentLine(1)
singlestudent.phoneNo = arrStudentLine(2)
singlestudent.averageScore = arrStudentLine(3)
arrStudent(counter) = singlestudent
counter += 1
Loop
Finally I run a for loop and compare the stdName property with textbox.text
Dim counter As Integer = arrStudent.Length
(debug here)
For i As Integer = 0 To counter - 1
If (String.Compare(arrStudent(i).stdName, txtStdName.Text) = 0) Then
lblPhoneNo.Text = arrStudent(i).phoneNo
End If
Next
and I add watch:

Why the compare return 1
Last edited: