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.
Printable View
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.
alter this to your needs
Code:'generates a random # between 6 and 1
Randomize
RandomInteger = Int((Rnd * 6) + 1)
'code from dennis
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.
d100 = DiceRoll(1,100)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
2d20 = DiceRoll(2,20)
3d10+3 = DiceRoll(3,10) + 3