Random password generator


First of all make a standard exe and make 2 text boxes name: Text1 Text2
Text1 - This will be where the user will type the length of the password

Text2 - Where the random password will display

Now crate a command button double click on it and enter this code-
VISUALBASIC Code
  1. 'Sets the variables
  2. Dim Characters As String
  3. Dim pwd As String
  4. Dim tStore As String
  5.  
  6. 'Stores which characters the generator will use.
  7. Characters = "acbdefghijklmnopqrstuvqxyz1234567890"
  8.  
  9.  
  10. For c = 1 To Text1.Text
  11. Randomize
  12.  
  13. 'Choose a random number
  14. tStore = Rnd * 36
  15. 'Rounds the numbers
  16. tStore = Round(tStore, 0)
  17.  
  18. 'This prevents is causing an error if the random number was 0
  19. If tStore = "0" Then
  20. tStore = "2"
  21. End If
  22.  
  23. 'Gets the position of the character from the number (say the random number was 3 the letter would be c etc... )
  24. pwd = pwd & Mid(Characters, tStore, 1)
  25.  
  26.  
  27. Next
  28.  
  29. 'After it's looped the length amount u set, It will display the password in text2.
  30. Text2.Text = pwd

Very simple but it will help! Here is an example i did
6 letters
gu8sl4

and 8 letters
dj7f5cd3
MOD-Dan's Avatar
Author:
Views:
2,265
Rating:
Posted on Sunday 21st October 2007 at 09:43 AM
Dalez
Dalez's Avatar
Yeah it says theres and error:
For c = 1 To Text1.Text
Posted on Sunday 15th July 2007 at 01:01 AM
Joshua
Joshua's Avatar
Hmm, seems to bee an Error...

For c = 1 To Text1.Text
Posted on Wednesday 11th July 2007 at 05:22 PM
FtH8er
FtH8er's Avatar
he asked so i told him, its not like im trying to take his tut over or nothing, cause its a nice basic vb tut.
Posted on Wednesday 11th July 2007 at 01:53 PM
vb_king
vb_king's Avatar
FtH8er you don't need to put that...
Posted on Wednesday 11th July 2007 at 01:21 AM
FtH8er
FtH8er's Avatar
umm I believe you put this under the defined variables:

On Error GoTo ErrorHandler

and then at the end of the thing you would put what you want the ErrorHandler to say so like this:

ErrorHandler:
MsgBox "You Have Created An Error And Cause The Program To Malfunction. Please Go Back And Correct Your Error.", vbInformation, "Exotic Calculator Error"


This is not a guarentee as i have yet to try it with this code, but it works with other things so dont get to mad if it done work lol
Posted on Sunday 17th June 2007 at 08:24 PM
Diablosblizz
Diablosblizz's Avatar
If somebody doesn't enter anything they I get an error.

How do I fix it so it shows a Error Message and not close the program.