VB掷骰子问题
发布网友
发布时间:2022-12-21 07:21
我来回答
共2个回答
热心网友
时间:2023-10-08 00:31
Private Sub Command1_Click()
Randomize
For i = 1 To 50
Select Case Int(Rnd * 6) + 1
Case 1: a = a + 1
Case 2: b = b + 1
Case 3: c = c + 1
Case 4: d = d + 1
Case 5: e = e + 1
Case Else: f = f + 1
End Select
Next
Print "点数1出现"; a; "次"
Print "点数2出现"; b; "次"
Print "点数3出现"; c; "次"
Print "点数4出现"; d; "次"
Print "点数5出现"; e; "次"
Print "点数6出现"; f; "次"
End Sub
热心网友
时间:2023-10-08 00:32
Private Sub Command1_Click()
Randomize
Dim A(6), b As Integer
For i = 0 To 5
A(i) = 0
Next
For i = 1 To 50
Select Case Int(Rnd() * 6 + 1)
Case 1
A(0) = A(0) + 1
Case 2
A(1) = A(1) + 1
Case 3
A(2) = A(2) + 1
Case 4
A(3) = A(3) + 1
Case 5
A(4) = A(4) + 1
Case 6
A(5) = A(5) + 1
End Select
Next
For j = 1 To 6
Print "点数" & j; "出现" & A(j - 1) & "次"
Next
End Sub