Visual Basic 6.0
Visual Basic 6.0
Generating Random ASCII Strings
See more PRNG Examples
Demonstrates how to generate random us-ascii strings.Chilkat Visual Basic 6.0 Downloads
Dim success As Long
success = 0
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
success = 0
Dim fortuna As New ChilkatPrng
Dim bDigits As Long
Dim bLowercase As Long
Dim bUppercase As Long
' Generate random strings having only lowercase chars (a-z)
' Disallow digits and uppercase and only allow lowercase
bDigits = 0
bUppercase = 0
bLowercase = 1
Dim i As Long
Debug.Print "-- only lowercase alpha (a-z)"
For i = 1 To 10
' Generate 20-character strings.
Debug.Print fortuna.RandomString(20,bDigits,bLowercase,bUppercase)
Next
' Allow both lowercase and uppercase alpha chars
bUppercase = 1
Debug.Print "-- lower and uppercase alpha (a-zA-Z)"
For i = 1 To 10
' Generate 20-character strings.
Debug.Print fortuna.RandomString(20,bDigits,bLowercase,bUppercase)
Next
' Allow digits (0-9)
bDigits = 1
Debug.Print "-- digits and lower/uppercase alpha (0-9a-zA-Z)"
For i = 1 To 10
' Generate 20-character strings.
Debug.Print fortuna.RandomString(20,bDigits,bLowercase,bUppercase)
Next
' Allow only digits (0-9)
bUppercase = 0
bLowercase = 0
Debug.Print "-- only digits (0-9)"
For i = 1 To 10
' Generate 20-character strings.
Debug.Print fortuna.RandomString(20,bDigits,bLowercase,bUppercase)
Next