我想製作一個程序,要求用戶登錄,如果輸入正確的用戶名和密碼,然後打開該用戶的窗體。我也只是現在做的方式是用戶名被存儲在一個變量,我想知道我怎麼可以在表單名稱使用的文字從變量,例如:Visual Basic,打開表格
用戶名=用戶1然後
FrmUser1。顯示
用戶名= JohnSmith對然後
FrmJohnSmith.show
這裏是從代碼的摘錄我迄今爲止:
Dim Path As String = "Account_File.text "
Dim Read_File() As String = File.ReadAllLines(Path)
Dim NoOfLines As Integer = Read_File.Length
Dim UserName(NoOfLines) As String
Dim Password(NoOfLines) As String
Dim LastNonEmpty As Integer = -1
Dim InputUserName As String = ""
Dim InputPassword As String = ""
If TxtUserName.Text = "" Then
MsgBox("Please enter a username.")
GoTo InvalidDetails
Else
InputUserName = TxtUserName.Text
End If
If TxtPassword.Text = "" Then
MsgBox("Please enter a Password.")
GoTo InvalidDetails
Else
InputPassword = TxtPassword.Text
End If
For i = 0 To NoOfLines
Dim SplitString() As String = Split(Read_File(i))
For j As Integer = 0 To SplitString.Length - 1
If SplitString(j) <> "" Then
LastNonEmpty += 1
SplitString(LastNonEmpty) = SplitString(j)
End If
Next
ReDim Preserve SplitString(LastNonEmpty)
LastNonEmpty = -1
UserName(i) = SplitString(0)
Password(i) = SplitString(1)
Next
For i = 0 To NoOfLines
If UserName(i) = InputUserName And Password(i) = InputPassword Then
frm.show()
Else
MsgBox("Either the username or password is incorrect.")
End If
Next
我從VB6重新簽名到VB.Net(變量初始值設定器語法) – 2015-02-06 18:11:51
謝謝我得到2混合有時 – Lazzer555 2015-02-06 18:32:48
您是否有帳戶文件中的每個用戶的自定義窗體? – LarsTech 2015-02-06 18:45:24