我一直在尝试创建一个登录系统,但找不到一个好的教程或代码。但后来我发现这个代码应该正常工作。除了有一点问题。问题是我得到了语法错误,我也无法找到解决方案这个错误。
你能帮忙吗?
当我写这个:do passline = TextBox2.Text userline = USERREAD.ReadLine 它说passline是一个语法错误。
这是代码:
If TextBox1.Text = "" Then
MsgBox("You need atleast 1 Character", MsgBoxStyle.Critical)
ElseIf My.Computer.FileSystem.DirectoryExists("C:\Users\Rebecca\Desktop\ACCOUNTS\ACCOUNTS" + TextBox1.Text + "\") Then
Dim USERREAD As System.IO.StreamReader = New System.IO.StreamReader("C:\Users\Rebecca\Desktop\ACCOUNTS\ACCOUNTS" + TextBox1.Text + "\" + "username.txt")
Dim userline As String
Dim PASSREAD As System.IO.StreamReader = New System.IO.StreamReader("C:\Users\Rebecca\Desktop\ACCOUNTS\ACCOUNTS" + TextBox2.Text + "\" + "password.txt")
Dim passline As String
Do passline = TextBox2.Text userline = USERREAD.ReadLine Console.WriteLine(passline)
Console.WriteLine(userline)
Loop Until userline Is Nothing
If TextBox2.Text = "" Then
MsgBox("Please enter a Password(", MsgBoxStyle.Critical, "ERROR")
ElseIf passline = PASSREAD.ReadLine() = True Then
MsgBox("Welcome to LoginSystem " + TextBox1.Text)
Form2.Show()
Me.Hide()
Else : MsgBox("The information you entered is Incorrect", MsgBoxStyle.Critical, "ERROR")
End If
End If
答案 0 :(得分:1)
语法错误是由Do
循环中缺少新行引起的,更改为:
Do
passline = TextBox2.Text
userline = USERREAD.ReadLine
Console.WriteLine(passline)
Console.WriteLine(userline)
Loop Until userline Is Nothing