Hallo! I'm a n00b, and I'm looking for a few lines of code in VB6 to implement this: I want to list a certain number of commands to execute, then tell my program to chose a random one among them and execute it: strictly speaking, I'm dealing with a MSAgent character, and I want him to make a face every 5 minutes. How can I achieve this, please?
+2
A:
Public Sub MakeFace()
'Reset random seed.
Randomize
'Generate a random integer with the specified range.
Dim Min As Integer, Max As Integer, N As Integer
Min = 1
Max = 5
N = Min + Round(Rnd) * Max
'Select and call the desired function.
Select Case N
Case 1
Call MakeHappyFace
Case 2
Call MakeSadFace
Case 3
Call MakeAngryFace
Case 4
Call MakeSmirkFace
Case 5
Call MakeFunnyFace
End Select
End Sub
JRS
2009-01-20 17:17:55
Isn't Round(Rnd) always 0 or 1?
recursive
2009-01-20 17:35:25