2011-12-10 2 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

클래스 메서드 (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 
관련 문제