Login With Input Box
May 8, 2008
Option Explicit
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdLog_Click()
‘
‘These codes will create a logon using Inputboxes that IS Case Sensitive.
‘
‘Create variables that will get the value from the Username and Password Inputbox.
Dim username As String
Dim password As String
username = txtUsername.Text
password = txtPassword.Text
If chkCase.Value = False Then
‘
‘This code doesn’t care what the casing is…
If LCase(username) = LCase(”userName”) Then
If LCase(password) = LCase(”pW”) Then
MsgBox “You have now gained access to my application!”
Else
MsgBox “Sorry, wrong password. I am now closing…”
Unload Me
End If
Else
MsgBox “Sorry, wrong username. Closing now…”
Unload Me
End If
Else
‘
‘This is Case Sensitive code…
If username = “userName” Then
If password = “pW” Then
MsgBox “You have now gained access to my application!”
Else
MsgBox “Sorry, wrong password…”
‘Unload Me
End If
Else
MsgBox “Sorry, wrong username…”
‘Unload Me
End If
End If
End Sub
Private Sub Form_Load()
Dim username As String
Dim password As String
username = InputBox(”Please enter your Username…”, “ Enter Username”, “username”)
If LCase(username) = LCase(”userName”) Then
password = InputBox(”Please enter your password…”, “ Enter Password”, “pW”)
If LCase(password) = LCase(”pW”) Then
MsgBox “You have now gained access to my application!”
Else
MsgBox “Sorry, wrong password. I am now closing…”
Unload Me
End If
Else
MsgBox “Sorry, wrong username. Closing now…”
Unload Me
End If
End Sub