View Single Post
 
Old 01-04-2013, 06:03 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Jennifer,

You will eventually get a 255 if you use 255. Try this:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim i As Long
Dim lngRandom As Long
Do
  i = i + 1
  lngRandom = CLng(Rnd() * 255)
  If lngRandom = 255 Then
    MsgBox "Bingo!  In " & i & " loops you reached max value."
    Exit Do
  End If
Loop
End Sub
Personally, I don't think it matters that much if you use an integer or long variable.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote