我已经做了几个月的A-Level计算,我决定制作一个与课堂上使用的方法相关的电话簿。对于我的考试,我不允许使用StreamReader等...但是,我可以使用FileOpen(1,“FILE NAME”,OpenMode.Binary)等方法。
我想将用户名和密码存储在一个文本文件中(我知道它不是一个好方法,但它链接到我的课程)。我的.txt文件格式如下: 用户名密码。 用户名2,密码2。
如果能够将每个用户名和密码存储在列表中,我能做些什么?
这就是我所拥有的......(不知道为什么它不起作用)
Private Sub CheckAccount()
Dim Username_File As New ArrayList
Dim Username_Temp As String = ""
Dim Password_File As New ArrayList
Dim Password_Temp As String = ""
FileOpen(1, "Users.txt", OpenMode.Binary)
Do While Not EOF(1)
Dim PosCount_Start As Integer = 0
Dim PosCount_End As Integer = 0
Dim TempChar As Char = ""
Do
FileGet(1, TempChar)
If TempChar = "," Then Exit Do
Username_Temp = Username_Temp + TempChar
PosCount_End = PosCount_End + 1
Loop
Username_Temp = Username_Temp.Substring(PosCount_Start, (PosCount_End - PosCount_Start))
Username_File.Add(Username_Temp)
PosCount_End = 0
Do
FileGet(1, TempChar)
If TempChar = "." Then Exit Do
Password_Temp = Password_Temp + TempChar
PosCount_End = PosCount_End + 1
Loop
Password_Temp = Password_Temp.Substring(0, PosCount_End)
Password_Temp = Password_Temp.Trim
Password_File.Add(Password_Temp)
PosCount_End = 0
Loop
FileClose(1)
For i = 0 To Username_File.Count - 1
Dim Temp As String
Temp = Username_File(i)
If Temp.ToLower = Username.ToLower Then
If Password = Password_File(i) Then
LoggedIn = True
End If
End If
Next
End Sub