Search Tools Links Login

password examples


This code shows three different samples of using low security password entry to a form. Yes this is quick, easy and some might think somewhat lame but for beginners these samples will be just fine and useful. It keeps prying eyes out of my stuff anyways. These code examples can easily be modified for more sophisticated routines. It just lays a basic foundation is all.

Original Author: Steve G

Inputs

'Just change the passwords to whatever you want

Assumptions

'N/A

Returns

'N/A

Side Effects

'No side effects

API Declarations

'None

Code

'This is just one of the examples showing a
'low security way to hard code form entry with
'a username and double password entry to the form.
'
'
'
Option Explicit
Public LoginSucceeded As Boolean
Private Sub Form_Load()
  Me.Caption = "Monkey Login "
End Sub
Private Sub cmdCancel_Click()
  LoginSucceeded = False
  Unload Me
End Sub
Private Sub cmdOK_Click()
Dim Pw1 As String '
Pw1 = "monkey" 'first password
'check combo box for population. If nothing
'return a msgbox dialog
If cmoUserName = "" Then
  MsgBox ("Type a Username")
Else
'Then check for first password
If txtPassword = Pw1 Then
'If correct password found go to verify second
Password2
End If
End If
End Sub
Private Function Password2()
Dim PW2 As String '
PW2 = "boy" 'second password
'check validity of second password
'then check if all correct, if so, load form
If txtPassword2 = PW2 Then
  LoginSucceeded = True
  MsgBox ("Access granted!")
  frmAbout.Show
  Unload Me
Else
'if only one password is correct and other empty
'remind user two passwords are needed
  MsgBox "You need both passwords to enter this program"
End If
End Function

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 86 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.