猿问

gotfocus控件使用函数?

有text1至text10 共10个文本窗口 也有10个gotfocus控件 当单击command按钮时 只计算获取标点的text文本窗口中的值 求具体代码

红颜莎娜
浏览 516回答 2
2回答

慕妹3146593

那不叫gotfocus控件,叫gotfocus事件Dim tt As TextBoxPrivate Sub Command1_Click()MsgBox tt.TextEnd SubPrivate Sub Text1_GotFocus()Set tt = Text1End SubPrivate Sub Text2_GotFocus()Set tt = Text2End Sub对类似问题建议使用控件数组,将Text1设置为控件数组,不管有多少Text,只需一个GotFocus事件即可:Dim tt As TextBoxPrivate Sub Command1_Click()MsgBox tt.TextEnd SubPrivate Sub Text1_GotFocus(Index As Integer)Set tt = Text1(Index)End Sub

噜噜哒

将text1至text10改名为txtText(1)至txtText(10)Dim GotFocusTextPrivate Sub Command1_Click()MsgBox txtText(GotFocusText).TextEnd SubPrivate Sub txtText_GotFocus(Index As Integer)GotFocusText = IndexEnd Sub
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答