General discussion

Locked

How to generate random letters in vb6.0

By markjenkins74 ·
Hi

Just wondering how I would generate random letters in VB 6.0?

Cheers
Mark

This conversation is currently closed to new comments.

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

All Comments

Collapse -

by john.a.wills In reply to How to generate random le ...

Use Rnd to get a number from 0 to 1. Multiply by 25, add 1, round to nearest integer. Convert 1 to A, 2 to B, etc.

Collapse -

by tom In reply to How to generate random le ...

Mark, try this out.....

Private Sub MakeRandom()
Dim theNum As Double
Dim theUpper As String
Dim theLower As String

' Upper Case
theUpper = Chr(64 + Rnd() * 10000000 Mod 26)
' Lower Case
theLower = Chr(96 + Rnd() * 10000000 Mod 26)

End Sub

Collapse -

by dvroman In reply to How to generate random le ...

Visually / Functionally The Function Would Be:
Chr$(Int(Rnd() * (Asc("Z") - Asc("A"))) + Asc("A"))
Cryptically It Would Be:
Chr$(Int(Rnd() * 25) + 65)

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

Related Discussions

Related Forums