喂! 我是一个n00b,我在VB6中寻找几行代码来实现这个: 我想列出一定数量的命令来执行,然后告诉我的程序在其中选择一个随机的命令并执行它:严格来说,我正在处理一个MSAgent角色,我希望他每5分钟做一个脸。 我怎么能实现这个目标呢?
答案 0 :(得分:2)
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