vb中label的caption问题.

2024-12-16 17:57:03
推荐回答(2个)
回答1:

Dim t As Long '//你没有定义这个全局变量,导致Command1_Click里和Form_Load里的t不是同一个变量
Form_Load
Private Sub Command1_Click()
Label1.Caption = t
t = t + 1
End Sub

Private Sub Form_Load()
t = 0
End Sub

回答2:

Private Sub Command1_Click()
Label1.Caption = Label1.Caption + 1
End Sub

Private Sub Form_Load()
Label1.Caption = 0
End Sub

或着

Dim t As Single
Private Sub Command1_Click()
t = t + 1
Label1.Caption = t
End Sub

Private Sub Form_Load()
Label1.Caption = 0
End Sub