icps

notes

Button_to_rand

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Private Sub CommandButton1_Click()

Dim min As Integer, max As Integer, p1 As Integer, p2 As Integer

min = 300
max = 1500

p1 = rand(min, max)
p2 = rand(min, max)

CommandButton1.Enabled = False

For i = 1 To 1500
    If p1 >= i Then
        工作表1.Range("B9") = Race()
    End If
    If p2 >= i Then
        工作表1.Range("H9") = Race()
    End If
Next i

CommandButton1.Enabled = True
End Sub

Private Function rand(min As Integer, max As Integer) As Integer
    rand = Int((max - min + 1) * Rnd() + min)
End Function

Private Function Race() As String
    ype = Array("英格蘭", "中國", "法蘭西", "羅馬", "蒙古", "羅斯", "蘇丹", "阿拔斯")
    Race = ype(Int((8) * Rnd()))
End Function