我有以下代码:
Dim userName As String
Dim passWord As String
'
' Populate userName and passWord from an online text file ...
'
If textbox1.text = userName AndAlso Textbox2.text = passWord Then
MsgBox("Welcome")
Else
MsgBox("UserName or Password incorrect")
End If
如何根据包含以下数据的网址中的在线文本文件验证用户和密码:
User;Password
答案 0 :(得分:0)
您可以使用WebClient课程方法 - DownloadFile
或DownloadString
或DownloadData
来阅读网址。
编辑:使用String.Split()方法分隔用户名和密码。
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim wc As New WebClient
Dim strings As String
strings = wc.DownloadString("weebly.com/uploads/9/5/8/9/9589176/passwords.txt";)
wc.Dispose()
Dim ar() as String = strings.Split(New String() {" "}, StringSplitOptions.RemoveEmptyEntries)
IF ar(0)=TextBox1.Text and ar(1)=TextBox2.Text Then
MessageBox.Show("Welcome ", "Welcome", MessageBoxButtons.OK, MessageBoxIcon.Information)
Form2.Show()
Else
MsgBox("Wrong Password Try Again")
End If
End Sub