2011-12-10 4 views
1

私は、次のコードを持っている:はオンラインテキストファイルからユーザ名およびパスワードを取得

User;Password 
:私のようなデータが含まれているURLからオンラインテキストファイルに対して、ユーザーとパスワードを確認するにはどうすればよい

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 

答えて

0

WebClientクラスメソッド(DownloadFileまたはDownloadStringまたはDownloadData)を使用してURLを読み取ることができます。

EDIT: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 
関連する問題