General discussion

Locked

Generating random letters in vb 6.0

By markjenkins74 ·
Hi all

Sorry should have explained this in more detail, here's what I want to do.
I have one form with 5 text boxes on it and need to generate random letters between A-F and random Numbers between 0-9

For Example: Text box 1 A0, Text 2 B7 Text 3 F9 Text 4 C6 Text 5 E8

So when the user clicks the command button, the program will generate random letters and numbers in each of the text boxes.

Could anyone maybe just point me in the direction with a couple of lines of code to perform this task.

Thanks for any help in advance

Cheers,
Mark

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by tom In reply to Generating random letters ...

Mark, Hi

Using the same concept as before, here's a method to get waht you need. The Randomize(Time) "seeds" the randomizer and ensures that you don't get the same sequence of numbers generating every time you start the program.

Good Luck!

Private Sub Form_Load()
Randomize (Time)
End Sub

Private Function AtoF() As String
' Upper Case
AtoF = Chr(65 + Rnd() * 862150000 Mod 6)

End Function

Private Function ZerotoNine() As String
' Numbers
ZerotoNine = Chr(48 + Rnd() * 862150000 Mod 10)

End Function

Private Sub Command1_Click()
Dim count As Integer

' Text1 is a control array of 5 text box's

For count = 0 To 4
Text1(count) = AtoF & ZerotoNine
Next count

End Sub

Collapse -

THE CODE

by manrick_021 In reply to Generating random letters ...

I NEED SPECIFIC CODE FOR A RANDOM QUESTION, I HAVE A !) TEXTBOX AND WHEN I'LL RUN A PROG. IT WILL BE RANDOMIZE...!?

Collapse -

i need more

by manrick_021 In reply to Generating random letters ...

spicific code for the random letters

Collapse -

WHY

by manrick_021 In reply to Generating random letters ...

ITS SO IMPORTANT PLS CAN TOU HELP ME AS SOON AS POSSIBLE

Back to Web Development Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums