|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 weiyingde 于 2019-11-1 09:59 编辑
Private Sub CommandButton1_Click()
On Error Resume Next
With ActivePresentation.Slides(1)
' For i = 1 To 500
'2、改为步长为2,代码如下:
For i = 1 To 500 Step 2
Randomize
rd = Int(Rnd * 4) + 1
sr = Choose(rd, "A", "B", "C", "D")
If rd = 1 Then a = a + 1
If rd = 2 Then b = b + 1
If rd = 3 Then c = c + 1
If rd = 4 Then d = d + 1
'1、第一个问题:提示摸了10的倍数。
N = N + 1
If N Mod 10 = 0 Then
m = m + 1
iStr = "次数:10的" & m & "倍。"
Else
iStr = "共摸了" & N & "次"
End If
' If N Mod 10 = 0 Then MsgBox Space(10) + "已经摸了" + N + "次" & vbCrLf & "是10的" + N / 10 & "倍。", vbCritical, "温馨提示"
With .Shapes("Label1")
.Visible = msoCTrue
With .OLEFormat.Object
.Caption = sr
.ForeColor = RGB(Int(Rnd * 255), Int(Rnd * 255), Int(Rnd * 255))
.BackColor = RGB(Int(Rnd * 255), Int(Rnd * 255), Int(Rnd * 255))
With .Font
.Name = "Arial Black"
.Bold = True
.Size = 40
End With
End With
End With
With .Shapes("Rectangle 20")
.Visible = msoTrue
.Height = i * 400 / 500
.Top = 419.62 - i * 384 / 500
With .Fill
.ForeColor.RGB = RGB(Int(Rnd * 255), Int(Rnd * 255), Int(Rnd * 255)) 'RGB(128, 0, 0)
.BackColor.RGB = RGB(Int(Rnd * 255), Int(Rnd * 255), Int(Rnd * 255)) 'RGB(170, 170, 170)
End With
End With
With Shapes("文本框 21")
With .TextFrame.TextRange
.Text = iStr
With .Font
.NameFarEast = "楷体"
.Bold = True
.Size = 28
.Color.RGB = RGB(Int(Rnd * 255), Int(Rnd * 255), Int(Rnd * 255))
End With
End With
End With
For j = 1 To 4
With .Shapes("Label" & 1 + j)
.Width = Choose(j, a, b, c, d) * 4
.Fill.BackColor.RGB = RGB(Int(Rnd * 255), Int(Rnd * 255), Int(Rnd * 255))
.Fill.ForeColor.RGB = RGB(Int(Rnd * 255), Int(Rnd * 255), Int(Rnd * 255))
With .OLEFormat.Object
.Caption = Choose(j, a, b, c, d) & "次"
.ForeColor = RGB(Int(Rnd * 255), Int(Rnd * 255), Int(Rnd * 255))
.BackColor = RGB(Int(Rnd * 255), Int(Rnd * 255), Int(Rnd * 255))
With .Font
.Name = "楷体"
.Bold = True
.Size = 18
End With
End With
End With
Next
tm1 = Timer
Do
DoEvents
Loop While Timer - tm1 < 1
Next
.Shapes("Label1").Visible = msoFalse
.Shapes("Rectangle 20").Visible = msoFalse
End With
End Sub
|
评分
-
1
查看全部评分
-
|