|
-
Aug 21st, 2000, 11:37 PM
#1
Thread Starter
New Member
Anyone know any code to make VB generate a random number between 1-100, 1-20, 1-10, and 1-6? For anyone who plays AD&D, i'm making a Magical Item Generating program.
-
Aug 21st, 2000, 11:41 PM
#2
Frenzied Member
alter this to your needs
Code:
'generates a random # between 6 and 1
Randomize
RandomInteger = Int((Rnd * 6) + 1)
'code from dennis
-
Aug 21st, 2000, 11:49 PM
#3
Hyperactive Member
You've come to the right man ;-)
I have a function for this at home.. but I can give you a quick and dirty cut of it now out of my head.
Code:
Function DiceRoll(NumDice As Integer, DieType As Integer) as Integer
Dim iDieNum as Integer
Randomize
DiceRoll = 0
For iDieNum = 1 to NumDice
DiceRoll = DiceRoll + Int(Rnd * DieType) + 1
Next iDieNum
End Function
d100 = DiceRoll(1,100)
2d20 = DiceRoll(2,20)
3d10+3 = DiceRoll(3,10) + 3
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
|