Hi, I am a beginner and below I have code for a long in form. My goal is
for the form to read a file of a list of users and thier passwords
....compare the text box inputs to the file and either start over or load the
main file.... I attempted to use a slect case..but its not working for me..
If someone has a better way of doing it..I would apperciate the help. Thank
you!
Option Explicit
Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click ()
'set the global var to false
'to denote a failed login
LoginSucceeded = False
Me.Hide
End Sub
Private Sub cmdOK_Click()
Dim User As String
Dim Password As String
Dim inCtr As Integer
Dim LoginSucceded As Boolean
Dim Login
Login = User + Password
Select Case LoginSucceded
'demo not a variable....exa mple..txt.Usern ame.text is what is needed
Case Demo
User = txtUserName = "Trial"
txtPassword = "Demo"
Form_Load.frmDa ta
Me.Hide
Case File
Open "C:\Windows\Dat aPwd\Pswd.pwd" For Random As #1
For i = 1 To 10
Get #1, User, Password
If Text.txtUserNam e = User And Text.txtPasswor d = Password Then
LoginSucceeded = True
Form_Load.frmDa ta
Me.Hide
Else: Next i
End If
Else
MsgBox "Invalid Password, try again!", , "Login"
txtPassword.Set Focus
SendKeys "{Home}+{En d}"
End If
End Sub
for the form to read a file of a list of users and thier passwords
....compare the text box inputs to the file and either start over or load the
main file.... I attempted to use a slect case..but its not working for me..
If someone has a better way of doing it..I would apperciate the help. Thank
you!
Option Explicit
Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click ()
'set the global var to false
'to denote a failed login
LoginSucceeded = False
Me.Hide
End Sub
Private Sub cmdOK_Click()
Dim User As String
Dim Password As String
Dim inCtr As Integer
Dim LoginSucceded As Boolean
Dim Login
Login = User + Password
Select Case LoginSucceded
'demo not a variable....exa mple..txt.Usern ame.text is what is needed
Case Demo
User = txtUserName = "Trial"
txtPassword = "Demo"
Form_Load.frmDa ta
Me.Hide
Case File
Open "C:\Windows\Dat aPwd\Pswd.pwd" For Random As #1
For i = 1 To 10
Get #1, User, Password
If Text.txtUserNam e = User And Text.txtPasswor d = Password Then
LoginSucceeded = True
Form_Load.frmDa ta
Me.Hide
Else: Next i
End If
Else
MsgBox "Invalid Password, try again!", , "Login"
txtPassword.Set Focus
SendKeys "{Home}+{En d}"
End If
End Sub
Comment