Reputation: 27
I'm batch file programmer but I'm experimenting with Small Basic. I know how to generate random numbers as a variable:
Math.getrandomnumber(number)
but I'm not sure how to generate random letters
Upvotes: 2
Views: 1713
Reputation: 2406
Just to round out the list of suggestions, you can do random anything using arrays.
hex[0] = "0"
hex[1] = "1"
hex[2] = "2"
...
hex[10] = "A"
hex[11] = "B"
hex[12] = "C"
hex[13] = "D"
hex[14] = "E"
hex[15] = "F"
randomHexDigit = hex[Math.GetRandomNumber(16) - 1]
The above will produce a random hex digit from the array.
Upvotes: 1
Reputation: 31
I don't really know, but if you are dealing with just a few letters, for example ABC, I would do this:
Code:
number = Math.GetRandomNumber(3)
If number = 1 Then
letter = A
Elseif number = 2 Then
letter = B
Elseif number = 3 Then
letter = C
EndIf
This should help.
Upvotes: 1
Reputation: 1017
Here you are! Like Tobberoth said, use text.GetCharacter for this. here is the code:
RandNum = Math.GetRandomNumber(25) + 65 'Get a number between 65 and 90 (See ASCII)
RandText = Text.GetCharacter(RandNum)
TextWindow.WriteLine(RandText)
Upvotes: 3