PDA

View Full Version : Vba Need Dice Continue Rolling?



icemail
12-08-2017, 02:16 AM
Hi everbody.

i try to dice game. My dice turning just once. but i need turning animation after result. My code is here.



Sub rolldice()
dicelayer = Int((6 * VBA.Rnd()) + 1)
'see result on sheet
Sheets("sheet1").Cells(1, 1).Value = dicelayer
'i need some code here for continue turning animation after stopping.
'wait is not work just stopping or puausing macro. But i need dice continue rolling.
Application.Wait Now() + TimeValue("00:00:01")
End Sub

SamT
12-08-2017, 07:18 AM
Dim numRolls as long
dim DelayTime as long
'
'
'
For numRolls = 1 to 10
'Roll Dice
dicelayer = Int((6 * VBA.Rnd()) + 1)
numRolls = numRolls + 1
Sheets("sheet1").Cells(1,).Value = dicelayer
'Delay to update Screen
For DelayTime = 1 to 1000
DelayTime = DelayTime + 1
Loop
Loop
'
'
'