View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
TK TK is offline
external usenet poster
 
Posts: 177
Default random number generation

nyn04

' Another way a little more random see "Randomize Statement"
' vba or vb help

Private Sub Label1_Click()
Dim n
' Initialize random-number generator.
' Uses the system timer
Randomize
' Generate random value between 1 and in this case 30.
n = Int((30 * Rnd) + 1)
Label1.Caption = n

End Sub


Good Luck
TK



wrote:

how would I write code to generate a random number only between 1-30
say with whole nubmers such as 1,2,3, 4 etc

thanks