The number of dice player rolled

Syaz

New Member
Joined
Jun 14, 2022
Messages
7
Office Version
  1. 2003 or older
Platform
  1. Windows
How to display the number of dice player rolled in vba in the message box after finish the line
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Welcome to the Board!

It seems that this question is missing a bit of information.
Can you describe your question in more detail?
If this part of an existing workbook? If so, how does it work?
Or perhaps you could walk us through an actual example of what you want to happen.
 
Upvote 0
Ad this code to your macro:
VBA Code:
MsgBox "Dice player rolled: " & number
 
Upvote 0
How to display the number of dice player rolled in vba in the message box after finish the line
The ‘START’ point must be located in cell A5 and the ‘FINISH’ point in cell AN5.
When writing the macro, you need to incorporate the following rules,
 The die is numbered between 1 to 6 and each number indicates how many steps the player can
move. This number is randomly sampled between the given range i.e 1 to 6.
 Whenever the player steps on a ‘yellow’ box, the player will be thrown back N number of steps
backwards. In this board game, there are 5 yellow boxes and they are positioned in cell G5, I5, U5,
AF5 and AM5 (see figure above).
 Similarly, if the player steps on a ‘blue’ box, the player will be rewarded 3 free steps forward. In
this board game, there are two blue boxes only and they are positioned in cell N5 and Z5 (see
figure above).
 Once the player crosses the finish line, use the MessageBox to display a message “FINISH!” with
the number of dice the player rolled.
Finally, assign your macro to a ‘Button’ and test whether it works or not.
 

Attachments

  • Fig (2).png
    Fig (2).png
    18.4 KB · Views: 9
Upvote 0
This looks like an assignment or homework. Note that we are not going to do you work for you, as that would not be ethical.

If you have some code for a particular part that you have attempted that you would like critiqued, then feel free to post that code, and we may be able to give you some tips to lead you in the right direction.
 
Upvote 0
This looks like an assignment or homework. Note that we are not going to do you work for you, as that would not be ethical.

If you have some code for a particular part that you have attempted that you would like critiqued, then feel free to post that code, and we may be able to give you some tips to lead you in the right direction.
 
Upvote 0
i want to make total player rolled the dice but everytime sum the total it will be 1
Sub BoardGame()

Dim dice
Dim x
Dim total

total = 0
index = 0

dice = Int((6 - 1 + 1) * Rnd + 1)
MsgBox dice
total=total+1

If ActiveCell.Row() <> 5 Or ActiveCell.Column() < 1 Or ActiveCell.Column() > 39 Then
MsgBox "FINISH!"
MsgBox total
Else
x = x + dice
ActiveCell.Offset(0, x).Select
End If
 
Upvote 0
In connection with
Do you want after each run:

1) msgbox : dice & total dice
for instant:

1st run
dice: 5
total: 5

2nd run
dice: 6
total: 11

...

2) If run in to special cells, i.e, U5 (back 5), first move to U5, then move back to P5?
It require a "OnTime" even. But how many seconds do you want to be delayed?
 
Upvote 0
More ideas:
Do you want to perfom each step like this:
Start in A5:
dice = 5
B5.activate
delay 1s
C5.activate
delay 1s
D5.activate
delay 1s
E5.activate
delay 1s
F5.activate
?
similar to back or forward.
 
Upvote 0
In connection with
Do you want after each run:

1) msgbox : dice & total dice
for instant:

1st run
dice: 5
total: 5

2nd run
dice: 6
total: 11

...

2) If run in to special cells, i.e, U5 (back 5), first move to U5, then move back to P5?
It require a "OnTime" even. But how many seconds do you want to be delayed?
1)1st run
Dice=5
Total =1

2nd run
Dice=4
Total=2

2)maybe just 2 sec

3)For the more ideas, i don't want to perform like that but thank you for the idea
 
Upvote 0

Forum statistics

Threads
1,216,101
Messages
6,128,835
Members
449,471
Latest member
lachbee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top