VB问题 怎么能使得焦点在哪个文本框,一点击按钮汉字就在哪个文本框里。

来源:百度知道 编辑:UC知道 时间:2024/06/30 11:15:57
设置一个按钮,一点击点击这个按钮时就能出现汉字。设置二个文本框,怎么能使得焦点在哪个文本框,一点击按钮汉字就在哪个文本框里。

Dim Index As Integer '窗体级变量

Private Sub Form_Load()
Index = 0
End Sub

Private Sub Text1_GotFocus()
Index = 0
End Sub

Private Sub Text2_GotFocus()
Index = 1
End Sub

Private Sub Command1_Click()
If Index = 0 Then Text1.Text ="汉字" Else Text2.Text ="汉字"
End Sub

Text1.TabIndex 设定比 Text2.TabIndex 小 就行了

Dim Index As Byte
Private Sub Command1_Click()
If Index = 1 Then
Text1.Text = "选种文本框1"
Else
Text2.Text = "选种文本框2"
End If
End Sub
Private Sub Text1_Click()
Index = 1
End Sub
Private Sub Text2_Click()
Index = 2
End Sub