Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleMake a random choice using the PickOne function
Keywordspick one, PickOne, random
CategoriesAlgorithms, Tips and Tricks
 
The PickOne function lets you quickly pick an item from a fixed list as in:

    lblResult.Caption = PickOne("Program", "Debug", "Email", "Write")
 
' Return a randomly selected argument.
Private Function PickOne(ParamArray choices() As Variant) _
    As Variant
Dim min_i As Integer
Dim max_i As Integer
Dim rnd_i As Integer

    min_i = LBound(choices)
    max_i = UBound(choices)
    rnd_i = Int((max_i - min_i + 1) * Rnd + min_i)
    PickOne = choices(rnd_i)
End Function
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated