|
-
Sep 1st, 2000, 02:44 AM
#1
Thread Starter
Lively Member
How can I generate a random character or number?
Thanks.
___________________________
Chris
-
Sep 1st, 2000, 02:49 AM
#2
Addicted Member
Hi,
try:
Code:
Dim myRandomNumber as integer
myRandomNumber = Int((10 * Rnd)+1)
This will generate a random number between 1 and 10.
Change the values to suit your needs.
Hope this helps
Shaun
Web/Application Developer
VB6 Ent (SP5), Win 2000,SQL Server 2000
-
Sep 1st, 2000, 02:52 AM
#3
transcendental analytic
Rnd returns a random number between 1 and 0
Rnd*6 a random number between 6 and 0 (and so on)
Int(rnd*6) returns a whole between 0 and 5.
asc(int(Rnd*25+65)) returns a random character
Use RAndomize, to avoid the same random series upon execution
[Edited by kedaman on 09-01-2000 at 03:54 AM]
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Sep 1st, 2000, 05:11 AM
#4
Fanatic Member
two things...
First.
I use this function:
Code:
Private Function Random(ByVal Min as Integer, ByVal Max as Integer) as Integer
Randomize Timer
Random = Int(Val(Rnd * Max) + Min)
End Function
So
Code:
Text1 = Random(1, 6)
Gives me a random number between 1 and 6, and
Code:
Text1 = Chr(Random(65, 90))
Will give me a random Uppercase Character.
Second.
No need to appologise about newbie questions. We've all been there.
r0ach™
Don't forget to rate the post
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|