Skip to content
tklltkioc edited this page Aug 28, 2021 · 4 revisions
Public a, b As Integer
Dim MyArray(10) As Integer

Private Sub CommandButton1_Click()

Dim name As Collection
Set name = New Collection
name.Add "", "1"
name.Add "", "2"
name.Add "", "3"
name.Add "", "4"
name.Add "", "5"
name.Add "", "6"
name.Add "", "7"
name.Add "", "8"
name.Add "", "9"
name.Add "", "10"
b = 0

Do While True
a = 1 + Int(Rnd() * 10)
Label1.Caption = name(a)
ShowImage (a + 1)


Dim Savetime As Single

Savetime = Timer

While Timer < Savetime + 0.005

DoEvents

Wend


If b = 1 Then

   Exit Do

End If

Loop


End Sub

Private Sub CommandButton2_Click()
Dim name As Collection
Set name = New Collection
name.Add "", "1"
name.Add "", "2"
name.Add "", "3"
name.Add "", "4"
name.Add "", "5"
name.Add "", "6"
name.Add "", "7"
name.Add "", "8"
name.Add "", "9"
name.Add "", "10"
b = 1
s = 0
For i = 1 To 10
s = s + MyArray(i - 1)
Next
If s < 110 Then
Do
a = Int((10 - 1 + 1) * Rnd + 1)
Loop While MyArray(a - 1) = 11
MyArray(a - 1) = 11
Label1.Caption = name(a)
ShowImage (a + 1)
Else
Label1.Caption = "都抽完了,你丫想累死我啊!"
End If
End Sub
Private Sub CommandButton3_Click()
    For i = 1 To 10
    MyArray(i - 1) = i
    Next
    Label1.Caption = "重置完成!"
    Image1.Visible = False
End Sub
Private Sub Image1_Click()

End Sub

Private Sub Label1_Click()

End Sub
Sub ShowImage(n)
Dim temppath As String

temppath = ActivePresentation.Path & "\Slide" & "n" & ".jpg" '临时图片文件路径

ActivePresentation.Slides(n).Export temppath, "jpg" '将指定页幻灯片导出为图片

Image1.Visible = False '先设置image控件为不可见,插入图片后再设为可见,否则图片不会显示
Image1.Picture = LoadPicture(temppath) 'image控件载入图片
Image1.Visible = True
End Sub

https://zhuanlan.zhihu.com/p/71948425

Clone this wiki locally