2011-12-10 81 views
1

我有以下代碼:獲得在線文本文件用戶名和密碼

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 

我如何從一個包含類似數據的URL驗證針對在線文本文件的用戶名和密碼:

User;Password 

回答

0

您可以使用WebClient類方法 - DownloadFileDownloadStringDownloadData來讀取URL。

編輯:使用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 
相關問題