VB中如何在一个按钮第一次单击改变按钮标题再一次单击又变成原标题

来源:百度知道 编辑:UC知道 时间:2024/05/13 06:14:28

定义全局变量
dim blnClicked as boolean
dim strCaption1 as string
dim strCaption2 as string
'strCaption1 和 strCaption2 的初始化自己做。
在按钮的Click()过程函数中添加如下代码:
blnClicked = not blnClicked
if(blnClicked) then me.caption=strCaption1
else me.caption = strCaption2
end if

Private Sub Command1_Click()
Command1.Caption = IIf(Command1.Caption = "原标题", "新标题", "原标题")
End Sub