Re: reading from a text file
Quote:
Originally posted by freddie_26
can anyone check and see what wrong with this code. i'm trying to read from a usernames and passwords from that file which i have coded in a text file.
Dim mAttempts As Integer
Dim Uname, pass As String
Dim sr As IO.StreamReader = IO.File.OpenText("user.txt")
Do While (sr.Peek <> -1)
Uname = sr.ReadLine
pass = sr.ReadLine
If txtUsername.Text = "" Then
MsgBox("User Name cannot be blank", MsgBoxStyle.Information)
Exit Sub
End If
If TxtPassword.Text = "" Then
MsgBox("Password cannot be blank", MsgBoxStyle.Information)
Exit Sub
End If
mAttempts = mAttempts + 1
If Uname <> txtUsername.Text Or pass = TxtPassword.Text Then
MsgBox("Please verify User Name and Password", MsgBoxStyle.Information)
ElseIf Uname = txtUsername.Text And pass = TxtPassword.Text Then
MsgBox("Logged in", MsgBoxStyle.Information)
If mAttempts = 3 Then
MsgBox("You had just 3 chances to verify")
End
End If
End If
Loop
sr.Close()
Exit Sub
what is the problem u get any error.. be specify to get help faster...