2 回答
繁华开满天机
TA贡献1816条经验 获得超4个赞
那不叫gotfocus控件,叫gotfocus事件
Dim tt As TextBox
Private Sub Command1_Click()
MsgBox tt.Text
End Sub
Private Sub Text1_GotFocus()
Set tt = Text1
End Sub
Private Sub Text2_GotFocus()
Set tt = Text2
End Sub
对类似问题建议使用控件数组,将Text1设置为控件数组,不管有多少Text,只需一个GotFocus事件即可:
Dim tt As TextBox
Private Sub Command1_Click()
MsgBox tt.Text
End Sub
Private Sub Text1_GotFocus(Index As Integer)
Set tt = Text1(Index)
End Sub
HUH函数
TA贡献1836条经验 获得超4个赞
将text1至text10改名为txtText(1)至txtText(10)
Dim GotFocusText
Private Sub Command1_Click()
MsgBox txtText(GotFocusText).Text
End Sub
Private Sub txtText_GotFocus(Index As Integer)
GotFocusText = Index
End Sub
添加回答
举报
0/150
提交
取消