|
-
Apr 11th, 2004, 08:14 PM
#1
Thread Starter
New Member
help
i have this code in my program
Dim account As String
Dim id As String
Dim password As String
Dim position As Integer
accountsfile = New System.IO.StreamReader("accounts.txt")
account = accountsfile.ReadLine()
position = InStr(account, " ")
id = Microsoft.VisualBasic.Left(account, position - 1)
password = Mid(account, position + 1)
If mskAccount.ClipText = id And txtPassword.Text = password Then
grporderform.Visible = True
Else
MsgBox("Account or Password is incorrect. Try again.")
mskAccount.Focus()
End If
but it only reads the first line in the txt file.
i have other ids and passwords in the txt file, so how do i code it so that it will read those ones as well?
-
Apr 11th, 2004, 09:10 PM
#2
Sleep mode
This loops in all the lines in the file
VB Code:
r = New IO.StreamReader("c:\test.txt")
While (r.Peek() > -1)
MessageBox.Show(r.ReadLine)
End While
r.Close()
-
Apr 11th, 2004, 09:33 PM
#3
Thread Starter
New Member
thanks, i used it..but i have another question...
While (accountsfile.Peek() > -1)
account = accountsfile.ReadLine()
position = InStr(account, " ")
id = Microsoft.VisualBasic.Left(account, position - 1)
password = Mid(account, position + 1)
If mskAccount.ClipText = id And txtPassword.Text = password Then
grporderform.Visible = True
Else
End If
End While
after else, i want to put a msgbox that says that the id or password it invalid, but when i do, and execute the program, type any of the ids or passwords that are valid, the msgbox will appear, and after clicking okay a few times, it will eventually stop and continue with the rest of the program. how can i add the msgbox?
-
Apr 11th, 2004, 09:42 PM
#4
Sleep mode
I don't really understand this condition but you can always use Exit While or Exit Sub where you want to get out of the loop .
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
|