so I am looking to either index a variable that is defined in a UDT of structpairofdice or erase the memory of the static intRollNum variable later on in the code. Preferably I'd like to index the sumdice variable although I haven't been able to figure it out, help is much appreciated
Option Explicit
Type structPairOfDice
diceOne As Integer
diceTwo As Integer
rollNum As Integer
sumDice As Variant
End Type
'Randomizes the dice between 1 and 6
Function RandomizeDice() As Integer
RandomizeDice = Application.WorksheetFunction.RandBetween(1, 6)
End Function
Sub RollDice(structDice As structPairOfDice)
Static intRollNum As Integer
intRollNum = intRollNum + 1
With structDice
.rollNum = intRollNum
.diceOne = RandomizeDice()
.diceTwo = RandomizeDice()
.sumDice = .diceOne + .diceTwo
End With
End Sub
Sub PrintResults(structDice As structPairOfDice)
Call RollDice(structDice)
With structDice
Debug.Print "Roll #: " & .rollNum
Debug.Print "Dice: " & .diceOne & ", " & .diceTwo
Debug.Print "Sum: "; .sumDice
End With
End Sub
Sub Main()
Dim structDice As structPairOfDice
SetThePoint structDice
'PrintResults structDice
End Sub