Click to See Complete Forum and Search --> : Urgent ! Need Help In Handling I/O Operation


SonicWave
July 13th, 2001, 11:43 PM
Good day !

I would like to ask, if I have a list of numeric datas, let say list of student IDs in a text file like this.

Example:

1991123115
1001155448
1236666554
1231311111
4894546122

Then I plan to have a form with a text field for the user to input their ID. After clicking OK button, how i going to write codes so that my program will compare the ID input by the user with those in the lists.

I try to use Input command but fail.

Do I miss out something here ? Below is the code that I write.

Static UserID(1500) As String
Dim CheckResult As Boolean
Dim Counter As Integer
Dim Control As Integer

Counter = 1
Open "C:\CLS\Members.bch" For Input As #1
Input #1, UserID(Counter)

Do Until (EOF(1) = True)
Counter = Counter + 1
Input #1, UserID(Counter)
Loop

Counter = Counter - 1

For Control = 1 To Counter
If UserID(Counter) = TxtID.Text Then
CheckResult = True
Else
CheckResult = False
End If
Next Control

Close #1

I need help here in urgent. Thanks a lot !

DLARLICK
July 14th, 2001, 10:53 AM
I'm not sure that you are having an I/O problem.

You should be reading the data in fine. I have modified your code for a form. cut and paste into a form and see if this is something similiar to what you were trying.


private UserID(1500) as string
private Counter as Integer

private Sub Command1_Click()
Dim CheckResult as Boolean
Dim Control as Integer

CheckResult = false
Do While Control <= Counter And CheckResult = false
If UserID(Control) = me.Text1 then
CheckResult = true
else
CheckResult = false
End If

Control = Control + 1
Loop

Debug.print CheckResult

End Sub

private Sub Form_Load()
Counter = 0
Open "C:\Members.txt" for input as #1
input #1, UserID(Counter)

Do Until (EOF(1) = true)
Counter = Counter + 1
input #1, UserID(Counter)
Loop

Counter = Counter - 1

Close #1
End Sub