ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dice (https://www.excelbanter.com/excel-programming/375998-dice.html)

spud

Dice
 
Need to no how to program dice to randomly generate instead of numbers words
on the click of a button.

Gary''s Student

Dice
 
First create the button in the usual way and assign the following macro to it:

Sub dice()
Dim s(6) As String
s(0) = "one"
s(1) = "two"
s(2) = "three"
s(4) = "five"
s(5) = "six"
v = Round(Rnd() * 5)
MsgBox (s(v))
End Sub
--
Gary's Student


"Spud" wrote:

Need to no how to program dice to randomly generate instead of numbers words
on the click of a button.


Gary''s Student

Dice
 
Sorry the previous dice were loaded. Use this instead:
Sub dice()
Dim s(6) As String
s(0) = "one"
s(1) = "two"
s(2) = "three"
s(3) = "four"
s(4) = "five"
s(5) = "six"
v = Round(Rnd() * 5)
MsgBox (s(v))
End Sub

--
Gary''s Student


"Spud" wrote:

Need to no how to program dice to randomly generate instead of numbers words
on the click of a button.



All times are GMT +1. The time now is 12:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com