Option Explicit
Private Sub Command1_Click()
Static j As Integer
j = j + 1 'j用于計數,每次單擊Command指令按鈕加1。
If j > 3 Then
MsgBox "隻能運作3次"
Exit Sub
End If
Dim i As Integer
i = Val(InputBox("請輸入數字1-3"))
Select Case i
Case 1
MsgBox "一"
Case 2
MsgBox "二"
Case 3
MsgBox "三"
Case Else
MsgBox "我隻會數到3"
End Select
End Sub