What is the syntax to cast to an integer?

<variable holding integer> = Int(<value that needs to be cast>)
'examples
MsgBox(Int("001")) 'produces 1
MsgBox(Int(12.1)) 'produces 12

 

 

What is the syntax to generate a random number?

<variable holding number> = (<max> - <min> + 1) * Rnd + <min>
'where max is the highest value the random number can be
'where min is the lowest value the random number can be
'cast to Int if a non-decimal random is desired
'examples

Dim myNumber As Integer
myNumber = Int ((20 - 10 + 1) * Rnd + 10)
'examples of values generated: 12, 10, 20, 23

Dim myNumber As Double
myNumber = (20 - 10 + 1) * Rnd + 10
'examples of values generated: 12.2, 10.2, 10, 20, 19.3, 12.2