Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim FILE_NAME As String = Cashierpath
System.IO.File.Exists(FILE_NAME) ' current
Dim objReader As StreamReader
Dim user As String = TextBox1.Text
Dim password As String = TextBox2.Text
Dim check As String
'Global Variable
'Dim DirPath7 As String = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Scrap Data\Cashier Info\Cashiers\")
For Each filename As String In IO.Directory.EnumerateFiles(DirPath7, "*.txt")
Dim fName As String = IO.Path.GetFileName(filename)
If user = fName & ".txt" Then
objReader = New StreamReader(fName)
check = objReader.ReadToEnd()
If password = check Then
MessageBox.Show("Welcome " & user & "!")
Close()
My.Forms.Home.Show()
Else
MessageBox.Show("Username or Password is incorrect")
End If
End If
Next
End Sub
When the user enters their "username" and "password" into the textbox's, and clicks on this button, i want this button to check if there is a textfile with the name of the username entered, and if theres a file with that username it must then read it and check if the password matches the string inside the file. if it doesnt match it, it must then display a messagebox saying that "Username or password is incorrect", but nothing happens when i click on this button. No error message appears either.
Can someone take a look at my code and tell me what im doing wrong?
What you have there is an awful way to handle user credentials!
Read this for more information: Salted Password Hashing - Doing it Right
Regardless, you're way over-coding it.
Elsewhere in your app (correct use of Combine):
' Global Variable
Friend Shared DirPath7 As String = IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.MyDocuments, "Scrap Data", "Cashier Info", "Cashiers")
Button Handler:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim User As String = TextBox1.Text.Trim
Dim Pass As String = TextBox2.Text.Trim
' Assemble the full expected file path, even if it might be malformed.
' The first case check protects against malformed path.
Dim FilePath As String = IO.Path.Combine(DirPath7, String.Format("{0}.txt", User))
Select Case True
Case User.Length = 0
MsgBox("Username is empty", vbExclamation, "Error")
Case Pass.Length = 0
MsgBox("Password is empty", vbExclamation, "Error")
Case Not IO.File.Exists(FilePath)
MsgBox("No file for User", vbExclamation, "Error")
Case Not IO.File.ReadAllText(FilePath) = Pass
MsgBox("Wrong Password", vbExclamation, "Error")
Case Else
MsgBox(String.Format("Welcome {0}!", User), vbOKOnly, "Success")
My.Forms.Home.Show()
End Select
End Sub
Dim objReader As StreamReader
Dim user As String = TextBox1.Text
Dim password As String = TextBox2.Text
Dim check As String
Dim fname = Path.Combine(DirPath7, String.Format("{0}.txt", user))
If File.Exists(fname) Then
Using objreader As New StreamReader(fname)
'objReader = StreamReader(fname)
check = objreader.ReadToEnd()
password = check
MessageBox.Show("Welcome " & user & "!")
Close()
My.Forms.Home.Show()
End Using
Else : MessageBox.Show("file not found, no user exists")
End If
removed the extra ".txt"
Added "Do Using" . . ."End Using"
Related
Assuming that there's value in all of the textfields and comboboxes. I want that when i click the edit button, there will be a pop up window that will require the users password before enabling the text fields.. is it possible? if yes? what's the code/syntax. Thanks in advance!
Yes, it possible, here i used Mike as a username and Mike124 as a password, here is the code to do that :
'Here is the click event when the user clicks on the edit button
Private Sub EditBUT_Click(sender As Object, e As EventArgs) Handles EditBUT.Click
RecheckUsername: Dim UserNameInput As String = InputBox("Please enter your username :")
If UserNameInput = "Mike" And UserNameInput <> "" Then
ReheckPassword: Dim PasswordInput As String = InputBox("Please enter your password :")
If PasswordInput = "Mike124" And PasswordInput <> "" Then
'Enable the all the fields here because the username and the password are correct
Else
'The password is wrong
MsgBox("Please check your password and try again")
GoTo ReheckPassword
End If
Else
'The username is wrong
MsgBox("Please check your username and try again")
GoTo RecheckUsername
End If
End Sub
If you want a way to store the username and the password, you can use My.Settings.Username and My.Settings.Password, but first you need to define them in the properties of your solution, just go to the Project tab in the Toolbar and click on Properties, then go to the Settings tab and set the Username and the Password variables.
Hope that helped you with what you need :)
Private Sub ACCOUNT_RECHECK()
Dim UserNameInput As String = InputBox("Please Enter your Username:")
Dim PasswordInput As String = InputBox("Please Enter your Password:")
Try
dbconnect.Open()
qInsert = "Select * from tblAdmin where Admin_UName='" & UserNameInput & "' and Admin_Password='" & PasswordInput & "'"
dbcommand = New OleDbCommand(qInsert, dbconnect)
dbcommand.ExecuteNonQuery()
Dim dr = dbcommand.ExecuteReader
If dr.Read = True Then
AccountType1 = dr("Admin_Type")
AccessGranted1 = True
dbconnect.Close()
Else
AccessGranted1 = False
End If
dbconnect.Close()
Catch ex As Exception
MsgBox(Err.Description)
End Try
End Sub
Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
ACCOUNT_RECHECK()
If AccountType1 = False Then
MsgBox("INVALID! YOU'RE NOT ALLOWED TO MODIFY THIS DATA!", MsgBoxStyle.Exclamation)
End If
If AccessGranted1 = True Then
MsgBox("ACCESS GRANTED!", MsgBoxStyle.Information)
If AccountType1 = 1 Then
TAGA_ENABLE()
TAGA_ENABLEB()
ElseIf AccountType1 = 2 Then
MsgBox("Sorry, your access role is only for viewing! Kindly ask the Admin to change your role to modify this data", MsgBoxStyle.Information)
End If
End If
End Sub
I am running a vb.net query into LDAP. I pull back the homedirectory. How can i write an IF statement to popup a msgbox if the homedirectory is empty versus the error "Object reference not set to an instance of an object."
code is below:
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
If TextBox2.Text = "" Then
MsgBox("Please enter a Network ID")
TextBox2.Focus()
Exit Sub
End If
Dim yourUserName As String = TextBox2.Text
Dim ADSearch As New DirectorySearcher()
Dim de As DirectoryEntry = GetDirectoryEntry()
ADSearch.SearchRoot = de
ADSearch.Filter = "(sAMAccountName=" & yourUserName & ")"
'ADSearch.PropertiesToLoad.Add("homedirectory")
Dim ADResult As SearchResult = ADSearch.FindOne()
If ADResult Is Nothing Then
MsgBox("User not found, please try again", MsgBoxStyle.OkOnly, "Not Found")
TextBox2.Text = ""
TextBox2.Focus()
Exit Sub
Else
Dim ADEntry As DirectoryEntry = New DirectoryEntry(ADResult.Path)
TextBox1.Text = (ADEntry.Properties("homeDirectory").Value.ToString)
End If
End Sub
You need to perform very basic null checking!
' if the "homeDirectory" hasn't been set -> then it will not show up in the SearchResult
If ADEntry.Properties("homeDirectory") Is Nothing Then
' do something
Else
If ADEntry.Properties("homeDirectory").Value Is Nothing Then
' do something
Else
' access your property here
TextBox1.Text = (ADEntry.Properties("homeDirectory").Value.ToString)
End If
End If
How to validate a username and password to login and then also check the usertype, based on which different events can be triggered?
for example admin has certain privileges and normal user has different privileges.
Public Class Login
Dim con As New OleDb.OleDbConnection
'new connection to database
Dim dbprovider As String
'to gets the probider name
Dim dbsource As String
'to gets the database provider name
Dim ds As New DataSet
'dataset to table
Dim da As OleDb.OleDbDataAdapter
'databaseAdapter to dataset and database
Dim sql As String
'sql command
Dim usrname1, pswd1, usrtype As String
Dim maxrows, incdec As Integer
'string variables
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'validation of username and password
If txtb_uname.Text = usrname1 And txtb_pwd.Text = pswd1 Then
If usrtype = "admin" Then
Score.Show()
Score.btn_delete.Enabled = False
Score.btn_update.Enabled = False
Score.Button2.Enabled = False
Score.Button1.Enabled = False
'username and password correct go to the netx page
ElseIf txtb_uname.Text = usrname1 And txtb_pwd.Text = "" Then
MsgBox("Enter Password")
'blank password control
ElseIf txtb_uname.Text = "" And txtb_pwd.Text = pswd1 Then
MsgBox("Enter Username")
'blank username control
ElseIf txtb_uname.Text = usrname1 And txtb_pwd.Text <> pswd1 Then
MsgBox("Invalid Password")
'incorrect pasword
ElseIf txtb_uname.Text <> usrname1 And txtb_pwd.Text = pswd1 Then
MsgBox("Invalid Username")
'incorrect username
ElseIf txtb_uname.Text = "" And txtb_pwd.Text = "" Then
MsgBox("enter Username")
'blank username and password
Else
MsgBox("invalid usertype")
End If
Else
MsgBox("Invalid Username & or Password")
'incorrect username and password
End If
End Sub
Lets assume that your database has a table containing the username, password and a boolean which is called something like isAdmin and can be set on true or false, depending on the users rights.
Now you have to use your DB connection to validate the username and the password. Here is a little example:
Public Shared Function Login(ByVal Name As String, ByVal Password As String) As Boolean
Shared OleDbConString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & My.Settings.Netzwerkpfad & ";" 'you'll have to enter your own provider etc. I just copied it from another project
Shared con As OleDbConnection = New OleDbConnection(OleDbConString) 'establish the connection
Shared cmd As New OleDbCommand 'your sql statement
Shared reader As OleDbDataReader 'Saving the data you'll get
Dim Checkpassword String = "" 'The string where you'll put the password you get from the databse
Dim isAdmin as boolean = False
Try
cmd.Connection = con
cmd.CommandText = "SELECT Password, isAdmin FROM tbl_User WHERE Name = '" & Name & "';" 'tbl_User is just the table name, this may be different in your DB
con.Open() 'opens the database connection
reader = cmd.ExecuteReader 'executes your command
Do While reader.Read
Checkpassword = reader("Password") 'reader("Password") returns the column "Password" in your databse
isAdmin = reader("isAdmin") 'Returns true or false depending on the users rights
Loop
If Password.Equals(Checkpassword ) Then 'Checks if the entered password is correct
If isAdmin = True Then 'Check if Admin and based on the outcome call the functions or save the outcome into global variables
Else
End If
Else
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error while trying to log in", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return Nothing
Finally
con.Close()
End Try
End Function
Public Class frmAdminLoginpage
Dim ErrorCount As Integer
Private Sub frmAdminLoginpage_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ErrorCount = 0
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
MessageBox.Show("Are you sure you want to Exit?", "Exit", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation)
Me.Close()
End Sub
Private Sub lblCreateAccount_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles lblCreateAccount.LinkClicked
frmRegister.Show()
Me.Hide()
End Sub
Private Sub lblForgotPassword_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles lblForgotPassword.LinkClicked
frmForgotPassword.Show()
Me.Hide()
End Sub
Sub ClearControls()
txtLoginID.Text = ""
txtLoginPassword.Text = ""
txtLoginID.Focus()
End Sub
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
'Clear text
ClearControls()
End Sub
Protected Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
Dim strConnectionString As String
Dim sqlCnn As SqlConnection
Dim sqlCmd As SqlCommand
Dim adapter As New SqlDataAdapter
Dim ds As New DataSet
Dim strSQL As String
' Check if ID or password is empty
If txtLoginPassword.Text = "" Or txtLoginID.Text = "" Then
MessageBox.Show("Please Enter your ID and Password.", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
' Both fields was supply
' Check if user exist in database
' Connect to Database
strConnectionString = "Data Source=LENOVO-PC; Initial Catalog=VB; Integrated Security=True"
Try
'Database records will verify the Staff ID, password and position from the Staff Database
strSQL = "Select * FROM Staff WHERE StaffID='" & txtLoginID.Text & "'And Password = '" & txtLoginPassword.Text & "'And Position='Administrator'"
'strSQL = "Select * FROM Staff WHERE Position='Administrator'"
sqlCnn = New SqlConnection(strConnectionString)
'Open Database Connection
sqlCnn.Open()
sqlCmd = New SqlCommand(strSQL, sqlCnn)
Dim sqlReader As SqlDataReader = sqlCmd.ExecuteReader
If sqlReader.Read() Then
frmSales_Admin.Show()
Me.Hide()
Else
' If user enter wrong ID and password
' Throw an error message
MessageBox.Show("Incorrect User ID and Password..", "Authentication Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
ErrorCount = ErrorCount + 1
'Clear all fields
txtLoginID.Text = ""
txtLoginPassword.Text = ""
'Focus on login ID field
txtLoginID.Focus()
'If login was not successful at the first time, the user will only have two more Login attempts left
If (ErrorCount = 1) Then
lblNotify.Text() = "You have 2 login attempts left"
'If login was not successful for the second time, the user will only have one more Login attempts left
ElseIf (ErrorCount = 2) Then
lblNotify.Text() = "You have 1 login attempt left"
'If login was not successful for the third time, the user will not have anymore attempts left
ElseIf (ErrorCount = 3) Then
MessageBox.Show(" You have exceeded the maximum login attempts. System is now exiting. ", " Error! ", MessageBoxButtons.OK, MessageBoxIcon.Error)
'The system will then exit after the message box is closed
Application.Exit()
End If
End If
Catch ex As Exception
MessageBox.Show("Failed to connect to Database.", "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
Private Sub chkShowPassword_CheckedChanged(sender As Object, e As EventArgs) Handles chkShowPassword.CheckedChanged
'To Make Password Visible
If chkShowPassword.Checked Then
txtLoginPassword.PasswordChar = ""
ElseIf chkShowPassword.Checked = False Then 'To make password not visible
txtLoginPassword.PasswordChar = "*"
End If
End Sub
Private Sub txtLoginID_DoubleClick(sender As Object, e As EventArgs) Handles txtLoginID.DoubleClick
txtLoginID.Clear()
txtLoginID.Focus()
End Sub
Private Sub btnBack_Click(sender As Object, e As EventArgs) Handles btnBack.Click
'To go back to the main page of the app
frmSmartBookStore.Show()
Me.Hide()
End Sub
Private Sub txtLoginPassword_KeyDown(sender As Object, e As KeyEventArgs) Handles txtLoginPassword.KeyDown
Dim strConnectionString As String
Dim sqlCnn As SqlConnection
Dim sqlCmd As SqlCommand
Dim adapter As New SqlDataAdapter
Dim ds As New DataSet
Dim strSQL As String
'If user press enter key on password textbox
If e.KeyCode = Keys.Enter Then
If txtLoginPassword.Text = "" Or txtLoginID.Text = "" Then
MessageBox.Show("Please Enter your ID and Password.", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
' Both fields was supply
' Check if user exist in database
' Connect to Database
strConnectionString = "Data Source=LENOVO-PC; Initial Catalog=VB; Integrated Security=True"
Try
strSQL = "Select * FROM Staff WHERE StaffID='" & txtLoginID.Text & "'And Password = '" & txtLoginPassword.Text & "'And Position='Administrator'"
'strSQL = "Select * FROM Staff WHERE Position='Administrator'"
sqlCnn = New SqlConnection(strConnectionString)
'Open Database Connection
sqlCnn.Open()
sqlCmd = New SqlCommand(strSQL, sqlCnn)
Dim sqlReader As SqlDataReader = sqlCmd.ExecuteReader
If sqlReader.Read() Then
frmSales_Admin.Show()
Me.Hide()
Else
' If user enter wrong username and password combination
' Throw an error message
MessageBox.Show("Incorrect User ID or Password..", "Authentication Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
ErrorCount = ErrorCount + 1
'Clear all fields
txtLoginID.Text = ""
txtLoginPassword.Text = ""
'Focus on login ID field
txtLoginID.Focus()
'If login was not successful at the first time, the user will only have two more Login attempts left
If (ErrorCount = 1) Then
lblNotify.Text() = "You have 2 login attempts left"
'If login was not successful for the second time, the user will only have one more Login attempts left
ElseIf (ErrorCount = 2) Then
lblNotify.Text() = "You have 1 login attempt left"
'If login was not successful for the third time, the user will not have anymore attempts left
ElseIf (ErrorCount = 3) Then
MessageBox.Show(" You have exceeded the maximum login attempts. System is now exiting. ", " Error! ", MessageBoxButtons.OK, MessageBoxIcon.Error)
'The system will then exit after the message box is closed
Application.Exit()
End If
End If
Catch ex As Exception
MessageBox.Show("Failed to connect to Database.", "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End If
End Sub
'if you have problems ask me at 0114280#kdu-online.com'strong text
End Class
Full code at bottom.
I've been getting an ArgumentException: "Illegal characters in path" whenever I attempt to save my text file in the program I've created.
My thoughts are that it has something to do with the directory path(path is chosen by user when prompted to open the file using an inputbox). My path on my computer being:
C:\Users\User\Desktop\HighScoreEditor
I've read tab characters can be the cause of this exception so my thoughts were maybe it's caused by the "\" in the directory path. I'm a 2nd year University Student so I may be completely wrong.
What I'm looking for is how to ignore this exception so that my file is saved, or a way to fix it so this exception does not occur.
My file is read from a directory path input by the user during an inputbox:
Dim message, title, defaultValue As String
Dim myValue As Object
Dim inFile As StreamReader
Dim strLine As String
' Set prompt.
message = "Enter a directory path to open your HighScore List."
' Set title.
title = "Which HighScore List should I open?"
defaultValue = "" ' Set default value.
' Display message, title, and default value.
myValue = InputBox(message, title, defaultValue)
' If user has clicked Cancel.
If myValue Is "" Then
Exit Sub
End If
Try
If File.Exists(myValue) = False Then
MessageBox.Show("Error: File/Directory Path """ & myValue & """ does not exist.")
ElseIf File.Exists(myValue) = True Then
inFile = File.OpenText(myValue)
Do While inFile.Peek <> -1
strLine = inFile.ReadLine()
txtScores.Text = txtScores.Text & vbCrLf & strLine
Loop
' Close the file.
inFile.Close()
End If
Catch ex As Exception
MessageBox.Show("Error: File/Directory Path """ & myValue & """ was found, however could not be opened." & vbCrLf & "" & vbCrLf & "Please make sure the list has a .txt file extension.")
End Try
Here is my code for my StreamWriter and save button:
Private Sub mnuFile_Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFile_Save.Click
Dim outFile As StreamWriter
outFile = File.CreateText(txtScores.Text)
outFile.WriteLine(txtScores.Text)
outFile.Close()
End Sub
------FULL CODE BELOW------
Imports System.IO
Public Class frmHighScore_Editor
Dim strTxt As String = "Click File > Open to display your HighScore List Here."
Private Sub mnuFile_Exit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFile_Exit.Click
' Terminates the program.
Me.Close()
End Sub
Private Sub mnuFile_Open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFile_Open.Click
Dim frmContinue As New frmContinue
frmContinue.ShowDialog()
Dim message, title, defaultValue As String
Dim myValue As Object
Dim inFile As StreamReader
Dim strLine As String
' Set prompt.
message = "Enter a directory path to open your HighScore List."
' Set title.
title = "Which HighScore List should I open?"
defaultValue = "" ' Set default value.
' Display message, title, and default value.
myValue = InputBox(message, title, defaultValue)
' If user has clicked Cancel.
If myValue Is "" Then
Exit Sub
End If
txtScores.Text = String.Empty
Try
If File.Exists(myValue) = False Then
txtScores.Text = strTxt
MessageBox.Show("Error: File/Directory Path """ & myValue & """ does not exist.")
ElseIf File.Exists(myValue) = True Then
txtScores.Text = String.Empty
If myValue.Contains("Blackjack.txt") Then
pbGame_Photo.Image = HighScores.My.Resources.Blackjack
lblGameName_Output.Text = "Blackjack"
ElseIf myValue.Contains("Mahjong.txt") Then
pbGame_Photo.Image = HighScores.My.Resources.Mahjong
lblGameName_Output.Text = "Mahjong"
ElseIf myValue.Contains("Minesweeper.txt") Then
pbGame_Photo.Image = HighScores.My.Resources.Minesweeper
lblGameName_Output.Text = "MineSweeper"
ElseIf myValue.Contains("Pinball.txt") Then
pbGame_Photo.Image = HighScores.My.Resources.Pinball
lblGameName_Output.Text = "Pinball"
ElseIf myValue.Contains("Solitaire.txt") Then
pbGame_Photo.Image = HighScores.My.Resources.Solitaire
lblGameName_Output.Text = "Solitaire"
Else
pbGame_Photo.Image = HighScores.My.Resources.Blank
lblGameName_Output.Text = "Your Game"
End If
inFile = File.OpenText(myValue)
Do While inFile.Peek <> -1
strLine = inFile.ReadLine()
Dim Res As String = ""
Dim Array(0) As Integer
For Each c As Char In strLine
If IsNumeric(c) Then
Res = Res & c
If CInt(Res) > Array(0) Then
Array(0) = CInt(Res)
End If
End If
Next
txtScores.Text = txtScores.Text & vbCrLf & strLine
lblScoreAchieved_Output.Text = Array(0)
Loop
' Close the file.
inFile.Close()
txtScores.Enabled = True
End If
Catch ex As Exception
txtScores.Text = strTxt
MessageBox.Show("Error: File/Directory Path """ & myValue & """ was found, however could not be opened." & vbCrLf & "" & vbCrLf & "Please make sure the list has a .txt file extension.")
End Try
End Sub
Private Sub frmHighScore_Editor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Set the focus.
gbGameInfo.Focus()
pbGame_Photo.Image = HighScores.My.Resources.Blank
' Disable text box on load since it's empty anyways.
txtScores.Enabled = False
txtScores.Text = strTxt
End Sub
Private Sub mnuFile_Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFile_Save.Click
Dim outFile As StreamWriter
outFile = File.CreateText(txtScores.Text)
outFile.WriteLine(txtScores.Text)
outFile.Close()
End Sub
End Class
------FULL CODE ABOVE------
myValue = InputBox(message, title, defaultValue)
That's a very poor way to ask for a filename. Use SaveFileDialog instead. Short from the intuitive dialog that any Windows user knows how to operate, it also automatically avoids that exception.
I have the following code:
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
How do I verify the user and password against an online text file from a URL that contains data like:
User;Password
You can use WebClient class methods - DownloadFile or DownloadString or DownloadData to read the URL.
EDIT: Use String.Split() method to separate username and password.
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