Properties :
Code:
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Password Generator"
ClientHeight = 2745
ClientLeft = 150
ClientTop = 720
ClientWidth = 4695
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2745
ScaleWidth = 4695
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command2
Caption = "Hide Password"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2400
TabIndex = 9
Top = 2160
Width = 1575
End
Begin VB.CheckBox Check3
Caption = "Uppercase"
BeginProperty Font
Name = "Tahoma"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 120
TabIndex = 6
Top = 1080
Width = 1335
End
Begin VB.CheckBox Check2
Caption = "Lowercase"
BeginProperty Font
Name = "Tahoma"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 120
TabIndex = 5
Top = 840
Value = 1 'Checked
Width = 1335
End
Begin VB.CheckBox Check1
Caption = "Add Numbers"
BeginProperty Font
Name = "Tahoma"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 120
TabIndex = 4
Top = 1320
Width = 1455
End
Begin VB.ComboBox Combo1
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
ItemData = "PasswordGen.frx":0000
Left = 2520
List = "PasswordGen.frx":0002
Style = 2 'Dropdown List
TabIndex = 3
Top = 1080
Width = 2055
End
Begin VB.CommandButton Command1
Caption = "Get Password"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 720
TabIndex = 1
Top = 2160
Width = 1575
End
Begin VB.TextBox Text1
Height = 285
Left = 0
Locked = -1 'True
TabIndex = 0
Top = 240
Width = 4695
End
Begin VB.Frame Frame1
Caption = "Options"
BeginProperty Font
Name = "Tahoma"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1095
Left = 0
TabIndex = 7
Top = 600
Width = 4695
Begin VB.Label Label2
Caption = "Select # Of Characters:"
BeginProperty Font
Name = "Tahoma"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 2520
TabIndex = 8
Top = 240
Width = 2055
End
End
Begin VB.Label Label1
Caption = "Your Password:"
BeginProperty Font
Name = "Tahoma"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 0
TabIndex = 2
Top = 0
Width = 4695
End
Begin VB.Menu Clip
Caption = "Clipboard"
Begin VB.Menu Copy
Caption = "Copy"
Shortcut = ^C
End
End
Begin VB.Menu About
Caption = "About..."
End
End
script :
Code:
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim PassSet, TextTxt, mylower, myupper
Private Sub About_Click()
Load Form2
Form2.Show
End Sub
Private Sub Command1_Click()
Text1.Text = ""
Randomize
Dim mypass, NumOfChars
Dim uporlow
NumOfChars = Combo1.Text
'Checking if Combo1 has value or if value under 3
If NumOfChars = "" Then
mynull = MsgBox("Error: Number of characters not selected!", vbExclamation, "Error!")
Exit Sub
ElseIf NumOfChars <= 3 Then
mynull = MsgBox("Error: Number of characters not selected!", vbExclamation, "Error!")
Exit Sub
End If
NumOfChars = Int(NumOfChars)
For i = 1 To NumOfChars
If Check2.Value And Check3.Value = 1 Then
'Deciding if uppercase or lowercase
Randomize
uporlow = Int((Rnd * 2) + 1)
If uporlow = 1 Then
myupper = 122
mylower = 97
Call NumChooser
Else
myupper = 90
mylower = 65
Call NumChooser
End If
ElseIf Check3.Value = 1 Then
myupper = 90
mylower = 65
Call NumChooser
ElseIf Check2.Value = 1 Then
myupper = 122
mylower = 97
Call NumChooser
Else
mynull = MsgBox("Error: You must select Lowercase or Uppercase!", vbExclamation, "Error!")
Exit Sub
End If
mypass = Int((myupper - mylower + 1) * Rnd + mylower)
Text1.Text = Text1.Text & Chr(mypass)
Next
End Sub
Private Sub Command2_Click()
If Text1.Text = "" Then
Exit Sub
End If
If PassSet = True Then
Text1.PasswordChar = ""
Text1.Text = TextTxt
Command2.Caption = "Hide Password!"
PassSet = False
ElseIf PassSet = False Then
TextTxt = Text1.Text
Text1.PasswordChar = "*"
Command2.Caption = "Unhide Password!"
PassSet = True
End If
End Sub
Private Sub Copy_Click()
Clipboard.SetText (Text1.Text)
End Sub
Private Sub Form_Load()
For i = 4 To 20
Combo1.AddItem (i)
Next
End Sub
Private Sub NumChooser()
'Adding number if number checkbox is selected and
'random generator chooses number over characters
If Check1.Value = 1 Then
Randomize
isnumorchar = Int((Rnd * 4) + 1)
If isnumorchar = 1 Then
mylower = 48
myupper = 57
End If
End If
End Sub
for VB.5