標題:
[發問]
ToggleButton按鈕
[打印本頁]
作者:
ssooi
時間:
2021-3-4 15:07
標題:
ToggleButton按鈕
設計一個ToggleButton1放在工作表1,希望去控制userform1的開啟或關閉
程式碼如附件
但是似乎只能開,卻無法關
而且開了之後,若點擊userform1右上角的關閉按鈕,ToggleButton1按鈕就偵測不到,就變得很尷尬
[attach]33091[/attach]
作者:
luhpro
時間:
2021-3-6 03:33
回復
1#
ssooi
你想要的結果是底下這樣嗎?
===== UserForm1 =====
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
With ActiveSheet
.ToggleButton1.Caption = " OFF "
.ToggleButton1.BackColor = RGB(248, 250, 250)
End With
Cancel = True
UserForm1.Hide
End Sub
複製代碼
===== 工作表1 =====
Private Sub ToggleButton1_Click()
If ToggleButton1.Caption = " ON " Then
ToggleButton1.Caption = " OFF "
ToggleButton1.BackColor = RGB(248, 250, 250)
UserForm1.Hide
Else
ToggleButton1.Caption = " ON "
ToggleButton1.BackColor = RGB(0, 255, 0)
UserForm1.Show
End If
End Sub
複製代碼
[attach]33101[/attach]
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)