Dice class example
Usage:
Option Explicit
Private mValue As Integer
Private mIsDouble As Boolean
Public Function roll() As Integer
Dim die1 As Integer
Dim die2 As Integer
die1 = Int(Rnd * 6) + 1
die2 = Int(Rnd * 6) + 1
mIsDouble = (die1 = die2)
mValue = die1 + die2
roll = mValue
End Function
Public Function diceValue() As Integer
diceValue = mValue
End Function
Public Function isDouble() As Boolean
isDouble = mIsDouble
End Function
Private Sub Class_Initialize()
roll
End Sub
Sample Use - One button on a form
Option Explicit
Private Sub Command1_Click()
Collection
Dim myDice As CDice
Set myDice = New CDice
' do stuff....
MsgBox myDice.diceValue & myDice.isDouble
myDice.roll
MsgBox myDice.diceValue & myDice.isDouble
Set myDice = Nothing
End Sub