在VB中,怎样做才能使按钮单击一次,按钮名称显示为A,再单击显示B,如此在A,B间循环?请各位高手指点...

2024-12-03 08:13:51
推荐回答(4个)
回答1:

楼上搞错了好像,应该把事件写在Command的Click()事件里面
Private Sub Command1_Click()
If Command1.Caption = "A" Then
Command1.Caption = "B"
ElseIf Command1.Caption = "B" Then
Command1.Caption = "A"
Else
Command1.Caption = "A"
End If
End Sub

回答2:

'放置一个按钮,把按钮的名称改为command1
Private Sub Command1_Click()
If Command1.Caption = "A" Then
Command1.Caption = "B"
Else
Command1.Caption = "A"
End if
end sub

回答3:

在button1_click事件写:

if button1.caption="A" Then
button1.caption="B"
else
button1.caption="A"
end if

回答4:

Private Sub Form_Load()
If Command1.Caption = "A" Then
Command1.Caption = "B"
ElseIf Command1.Caption = "B" Then
Command1.Caption = "A"
Else
Command1.Caption = "A"
End If
End Sub