Hi,

I have created a board gamer's aid in a Dice rolling workbook. Essentially it rolls a number of die 10's as specified by the user and shows the sum of the values rolled. The game it is doing this for requires massive amounts of die 10's to be rolled. Everything looked OK when I was choosing lesser numbers of die 10's to roll. But when I tested 30, for example things started to get flaky. Specifically with a die 10, results of 1 to 10 can be rolled. But for some reason the random generator was not rolling anything above 200 in sum. Confused, I looked at the average (sum/number of dice) and it consistently stayed between 5.0 to 5.9. Given that 30 die 10 can result in maximal sum of 300 and a minimal sum of 30, this did not make any sense that I could not get a sum of higher than 200.

I know that average between 30 and 300 is 165 and that equals an average die roll of 5.5. But averages tend to go up and down and not stay fixed at certain scale.

I checked on Google but could not find any specific information on the 'rnd' function in VB other than the generic stuff barfed out by Microsoft. I remember reading that Excel creates a pseudo-randomized number but I am not sure if this implies that I cannot use Excel for creating randoms numbers in dice rolling applications. Or perhaps I am not understanding the mathematics of it all.

Other than the non-random issue, my code works perfectly as intended.

My code:

I have created a board gamer's aid in a Dice rolling workbook. Essentially it rolls a number of die 10's as specified by the user and shows the sum of the values rolled. The game it is doing this for requires massive amounts of die 10's to be rolled. Everything looked OK when I was choosing lesser numbers of die 10's to roll. But when I tested 30, for example things started to get flaky. Specifically with a die 10, results of 1 to 10 can be rolled. But for some reason the random generator was not rolling anything above 200 in sum. Confused, I looked at the average (sum/number of dice) and it consistently stayed between 5.0 to 5.9. Given that 30 die 10 can result in maximal sum of 300 and a minimal sum of 30, this did not make any sense that I could not get a sum of higher than 200.

I know that average between 30 and 300 is 165 and that equals an average die roll of 5.5. But averages tend to go up and down and not stay fixed at certain scale.

I checked on Google but could not find any specific information on the 'rnd' function in VB other than the generic stuff barfed out by Microsoft. I remember reading that Excel creates a pseudo-randomized number but I am not sure if this implies that I cannot use Excel for creating randoms numbers in dice rolling applications. Or perhaps I am not understanding the mathematics of it all.

Other than the non-random issue, my code works perfectly as intended.

My code:

VBA Code:

```
Sub Roll10()
Dim neXx As Integer ' the for/next loop initiator
Dim numbOfDicE As Integer ' the number of dice that will be needed to be rolled
Dim totalSumMed As Integer ' the total sum of the dice
Dim rolLED10 As Integer ' the actual d10 results
numbOfDicE = Sheets(1).Cells(7, 10).Value ' loads how many dice I need to roll into a for/next loop
For neXx = 1 To numbOfDicE
rolLED10 = Int((10 - 1 + 1) * Rnd + 1)
totalSumMed = totalSumMed + rolLED10
Next neXx
Sheets(1).Cells(7, 16).Value = totalSumMed
MsgBox "Average rolled: " & (totalSumMed / numbOfDicE)
End Sub
```

Last edited by a moderator: