Hey, what's up...here's a sample for you.
I'd open a new project and paste this in there. Then make your modifications where ever. You'll notice when the form loads up, it populates the Bodies Collection. From there it just calls one out at random. You can see the output by making a cheap test, In my case it's "MsgBox GetRandBody" GetRandBody() returns as a hahahahahahahaha
Hope this helps...any other questions?
-Brad
Option Explicit
'Body Randomizer - by SuperBrad
'This may seem like a morbid example, but it works...
Public Bodies As New Collection 'Public Body Collection...
'Returns your random body as a string for usage anywhere.
Public Function GetRandBody() As String
GetRandBody = CStr(Bodies(Random(1, Bodies.Count)))
End Function
'Loads your body string into the Bodies Collection
Public Function LoadBodies(strBody As String)
Bodies.Add strBody
End Function
'This Function Generates Your Random Number (The High is the body count)
Public Function Random(lngLow As Long, lngHigh As Long) As Long
Rnd -1
Randomize
Random = Int((lngHigh - lngLow + 1) * Rnd(Rnd)) + lngLow
End Function
Private Sub Command1_Click()
End Sub
Private Sub Form_Load()
Set Bodies = New Collection
LoadBodies "This is a body1"
LoadBodies "This is a body2"
LoadBodies "This is a body3"
LoadBodies "This is a body4"
MsgBox GetRandBody
End Sub
__________________
Mr. T!
|