|
麻烦帮我看一下,下面的代码是什么问题:
需实现:点击 按钮 后,循环2000次,记录下摸到A、B、C、D的次数,再显示出来。
Private n As Integer '申明私有变量,好在过程结束后,能够存储数值。
Private a As Integer '记录摸到A的次数
Private b As Integer '记录摸到B的次数
Private c As Integer '记录摸到C的次数
Private d As Integer '记录摸到D的次数
Private Sub CommandButton1_Click()
Dim shps As Shapes
Dim shp As Shape
Dim i As Integer
Dim arr
arr = Array("A", "B", "C", "D")
For n = 1 To 2000
Randomize
rd = Int(Rnd * 4) '从上面的数组中随机选取
If rd = 0 Then a = a + 1
If rd = 1 Then b = b + 1
If rd = 2 Then c = c + 1
If rd = 3 Then d = d + 1
Next
With ActivePresentation.Slides(1)
Set shps = .Shapes
For Each shp In shps
If shp.Type = 1 Then shp.Delete
Next
For i = 1 To 2
lf = 190
tp = Choose(i, 250, 300)
wd = 450
ht = 50
nm = Choose(i, "字母", "数字")
With shps.AddShape(1, lf, tp, wd, ht)
.Fill.BackColor.RGB = vbGreen
.Name = nm
With .TextFrame.TextRange
.Text = Choose(i, "A、B、C、D分别被摸到" & a & "次、" & b & "次、" & c & "次、" & d & "次", "你一共摸了:" & n & "次")
With .Font
.NameOther = IIf(i = 1, "Arial Black", "楷体")
.NameAscii = IIf(i = 1, "Arial Black", "楷体")
.NameFarEast = IIf(i = 1, "Arial Black", "楷体")
.Bold = True
.Size = IIf(i = 1, 15, 35)
.Color.RGB = vbYellow
End With
End With
End With
Next
End With
End Sub
上面这段代码,有问题,该 怎么改啊
已改好 求助.rar
(35.31 KB, 下载次数: 11)
|
|