|
-
Mar 25th, 2003, 07:26 AM
#1
Thread Starter
New Member
reading from a text file
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
-
Mar 25th, 2003, 07:35 AM
#2
Fanatic Member
Re: reading from a text file
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...
-
Mar 25th, 2003, 07:45 AM
#3
Thread Starter
New Member
the code is being run but when i enter the username and password and error is generated and a grenn line appear over the
dim sr as io.streamreader =
-
Mar 25th, 2003, 08:05 AM
#4
Fanatic Member
currently i am away from my desk... so cannot test it... what is the message u get try using try ....catch...end try and see what is the error message u get
-
Mar 25th, 2003, 08:17 AM
#5
I do not have .Net on this machine, but I think it should be:
VB Code:
Dim sr As IO.StreamReader = New IO.File.OpenText("user.txt")
-
Mar 26th, 2003, 05:09 AM
#6
Sleep mode
Make sure you are referring to the right path .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|