Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Random string generator. Any length of string. ...
Author:
DGH
E-mail:
Click to e-mail author
Submitted:
10/13/2002
Version:
VB6
Compatibility:
VB6
Category:
String Manipulation
Views:
12996
Random string generator. Any length of string.
Declarations:
'** You need a label 'lblResult', a text '** box 'txtUserQuant' and two command buttons one '** called 'cmdRun' and the other 'cmdQuit' This is '** fully commented and will therefore help beginners. '** it uses chr(*) conversions and a simple loop with '** some iteration '**************************************************** ' Written by DGH 13/10/2002 denis.hadley@virgin.net ' Any comments regarding this code please feel free to ' mail me ' Dim Result, AA Dim Quant Dim Chars Dim UQuant As Single ' As Single will allow the code to use the number ' entered in text field as a number not text. ' text vars cannot be added to.
Code:
Private Sub cmdQuit_Click() End ' Get me outta here End Sub Private Sub cmdRun_Click() Result = "" ' Blank the result variable UQuant = txtUserQuant.Text ' Pull User Quantity in Quant = 0 ' Set Quant to 0 Do Until UQuant = Quant ' Set quailfier Run: ' Lbl 4 goto @ if stmnt AA = Int(Rnd * 122) + 1 ' Random 1 to 122 ' ASCII codes 48 = 0 and 57 = 9 therefore 0 to 9 are ok ' 65 = A & 90 = Z therefore A to Z upper case are ok ' 97 = a & 122 = z therefore a to z lower case are ok If AA < 48 Or _ AA > 57 And _ AA < 65 Or _ AA > 90 And _ AA < 97 Or _ AA > 122 Then GoTo Run ' AA has failed selection so ' return to get new number End If Chars = Chr(AA) ' Convert value to character Result = Result & Chars ' Add chars to result Quant = Quant + 1 ' Add one to count for loop Loop ' End of loop lblResult.Caption = Result ' Show result End Sub Private Sub Form_Load() ' Get random numbers from system time. ' This will make numbers truely random Randomize End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement