This is my first ever tutorial so apologies if there are any mistakes.
Well we got a lot to go through lets get started!
This will be split in to two (2) Parts A and B
Part A will be Design
and Part B will be coding
(Important things are highlighted in bold)
PART A - DESIGN
Make your PasswordGenerator (PW) about 329, 261 In height and width
insert:
1) Menustrip
2) Button
3) 3 Checkboxes
4) 2 Labels
5) Textbox
6) NumericUpdown
7) Progress bar
Now lay them out as shown in the image below and name them as shown.
(NB: Don't; change the actual names of the objects leave them default e.g button1 only change display name, unless you know what your doing.)
Also where it says "File" under Menu-strip-one click it and put a "Save" under it
Now click Textbox1 hit the Triangle in he top right hand corner and make it double line. Then in it's properties set it to Readonly and ScrollBars Both
PWGEN full image..JPG 25.72K
697 downloadsOK Now we have done that lets change the behaviour of the PW.
Capture2..JPG 56.1K
419 downloadsOK click outside of the border of Form1. Lets change it's Text to PasswordGenerator. Second
where it says MaximiseBox make this False
Then scroll to top of the properties and where it says FormBorderStyle this will be Fixed3D or anything of your choice.
OK we are done here.
PART B - CODING
One - Double Click Form 1
Enter this code:
' This will make label2 text show as nothing you will understand why later
Label2.Text = ""
Two - Double click File>Save
Enter this Code:
Now notice the dlg.filter you can add more file types if you like
the dlg.InitialDirectory is the directory the save-dialog will open up and show.
Using dlg As SaveFileDialog = New SaveFileDialog dlg.Title = "Save" dlg.Filter = "Rich Text Files (*.rtf)|*.rtf|Html File (*.html)| *.Html|Text File (*.txt)|*.txt" dlg.CheckPathExists = True dlg.InitialDirectory = "C:\" dlg.DefaultExt = "txt" Dim myReturn As DialogResult = dlg.ShowDialog() If System.Windows.Forms.DialogResult.OK.Equals(myReturn) Then System.IO.File.WriteAllText(dlg.FileName, TextBox1.Text) End If End Using
Thrid - Double Click Button one and insert this. ( I have annotated this with comments ''')
NumericUpDown1.Text.Trim()
If CheckBox1.Checked = False And CheckBox2.Checked = False And CheckBox3.Checked = False Then
MsgBox("You Must Select A Method ", MsgBoxStyle.Critical) 'You can always change your message
End If
If Val(NumericUpDown1.Text) <= 3 Then 'You can change the minimum number
MsgBox("Please enter a number higher than three", MsgBoxStyle.Critical, )
Exit Sub 'You can change your mwssage
End If
If Val(NumericUpDown1.Text) > 78 Then 'You can change the maximum number.
MsgBox("number is too high max 78", MsgBoxStyle.Critical, )
Exit Sub
End If
TextBox1.Text = GenerateCode()
End Sub
Public Function GenerateCode()
Dim intRnd As Integer
Dim intStep As Integer = Nothing
Dim strname As String
Dim intlength As Integer
Dim strinputstring As String = ""
Dim Numbers As String = "1234567890"
Dim Lower As String = "abcdefghijklmnopqrstuvwxyzyz"
Dim Upper As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZYZ"
Dim intnamelength As Integer = 1
If CheckBox1.Checked Then strinputstring &= Lower
If CheckBox2.Checked Then strinputstring &= Numbers
If CheckBox3.Checked Then strinputstring &= Upper
intlength = Len(strinputstring)
Integer.TryParse(NumericUpDown1.Text, intnamelength)
Randomize()
strname = ""
For inStep = 1 To intnamelength
intRnd = Int(Rnd() * intlength) + 1
strname = strname & Mid(strinputstring, intRnd, 1)
Next
Return strname
End Function
Fourth - Double Click Textbox1 insert this:
Now back to that label two thing look at the code and you can see it's text is going to change if the Password is strong enough xD:P
If TextBox1.TextLength < 9 Then ProgressBar1.Value = 5 End If If TextBox1.TextLength > 9 Then ProgressBar1.Value = 25 End If If TextBox1.TextLength > 19 Then ProgressBar1.Value = 50 End If If TextBox1.TextLength > 30 Then ProgressBar1.Value = 75 End If If TextBox1.TextLength > 51 Then ProgressBar1.Value = 100 End If If TextBox1.TextLength < 8 Then Label2.Text = "Poor!!" Label2.ForeColor = Color.White Label2.BackColor = Color.Red Me.BackColor = Color.Red MenuStrip1.BackColor = Color.Red CheckBox1.ForeColor = Color.White CheckBox2.ForeColor = Color.White CheckBox3.ForeColor = Color.White MenuStrip1.ForeColor = Color.White Label1.ForeColor = Color.White End If If TextBox1.TextLength > 8 Then Label2.Text = "Good" Label2.ForeColor = Color.White Label2.BackColor = Color.Green Me.BackColor = Color.Green MenuStrip1.BackColor = Color.Green CheckBox1.ForeColor = Color.White CheckBox2.ForeColor = Color.White CheckBox3.ForeColor = Color.White MenuStrip1.ForeColor = Color.White Label1.ForeColor = Color.White End If If ProgressBar1.Value > 20 Then Label2.Text = "Excellent" Label2.ForeColor = Color.White Label2.BackColor = Color.Green End If If ProgressBar1.Value > 50 Then Label2.Text = "Outstanding" Label2.ForeColor = Color.White Label2.BackColor = Color.Green End If End Sub
OK guys this is it if I missed anything I am sorry I am kinda tired lol 00:08 here I will be happy to help anyone who is stuck just reply here don't ask something to complicated I am still new myself lol (School Student).
Thanks for reading!
( YouTube - How to make password Generator ) <<<<
Edited by CriticalError, 27 July 2010 - 03:55 AM.


Sign In
Create Account


Back to top











