【发布时间】:2020-05-17 06:04:18
【问题描述】:
我正在制作一张表格来帮助数独,并有从 1 到 9 的命令按钮,按下时从数字变为空白。 每个按钮的代码是:-
Private Sub CommandButton1_Click()
If CommandButton1.Caption = "1" Then CommandButton1.Caption = "" Else CommandButton1.Caption = "1"
End Sub
Private Sub CommandButton2_Click()
If CommandButton2.Caption = "2" Then CommandButton2.Caption = "" Else CommandButton2.Caption = "2"
End Sub
Private Sub CommandButton3_Click()
If CommandButton3.Caption = "3" Then CommandButton3.Caption = "" Else CommandButton3.Caption = "3"
End Sub
Private Sub CommandButton4_Click()
If CommandButton4.Caption = "4" Then CommandButton4.Caption = "" Else CommandButton4.Caption = "4"
End Sub
Private Sub CommandButton5_Click()
If CommandButton5.Caption = "5" Then CommandButton5.Caption = "" Else CommandButton5.Caption = "5"
End Sub
Private Sub CommandButton6_Click()
If CommandButton6.Caption = "6" Then CommandButton6.Caption = "" Else CommandButton6.Caption = "6"
End Sub
Private Sub CommandButton7_Click()
If CommandButton7.Caption = "7" Then CommandButton7.Caption = "" Else CommandButton7.Caption = "7"
End Sub
Private Sub CommandButton8_Click()
If CommandButton8.Caption = "8" Then CommandButton8.Caption = "" Else CommandButton8.Caption = "8"
End Sub
Private Sub CommandButton9_Click()
If CommandButton9.Caption = "9" Then CommandButton9.Caption = "" Else CommandButton9.Caption = "9"
End Sub
我想复制并过去这九个按钮,并将代码保留在命令按钮中,但在代码中更改按钮编号,但其余代码保持不变。有可能吗。
Private Sub CommandButton10_Click()
If CommandButton1.Caption = "1" Then CommandButton1.Caption = "" Else CommandButton1.Caption = "1"
End Sub
【问题讨论】: