Private oTextBox As Object
Private Sub CommandButton1_Click()
If Not oTextBox Is Nothing Then
MsgBox oTextBox.Name
End If
End Sub
Private Sub TextBox1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Set oTextBox = Me.ActiveControl
End Sub
Private Sub TextBox2_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Set oTextBox = Me.ActiveControl
End Sub
Private oTextBox As Object
Private Sub TextBox1_GotFocus()
Set oTextBox = Me.TextBox1
End Sub
Private Sub TextBox2_GotFocus()
Set oTextBox = Me.TextBox2
End Sub
Private Sub CommandButton1_Click()
If Not oTextBox Is Nothing Then
MsgBox oTextBox.Name
End If
End Sub
Có cách nào để con trỏ chuột nằm sau text trong một textbox khi dùng sự kiện DoubleClick không aBạn đặt tiêu đề một nơi, lại hỏi một ngã.
"Xác định con trỏ chuột đang chọn Textbox nào?"
Sự kiện trong Userform:
--------------PHP:Private oTextBox As Object Private Sub CommandButton1_Click() If Not oTextBox Is Nothing Then MsgBox oTextBox.Name End If End Sub Private Sub TextBox1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) Set oTextBox = Me.ActiveControl End Sub Private Sub TextBox2_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) Set oTextBox = Me.ActiveControl End Sub
Sự kiện trong Worksheet:
PHP:Private oTextBox As Object Private Sub TextBox1_GotFocus() Set oTextBox = Me.TextBox1 End Sub Private Sub TextBox2_GotFocus() Set oTextBox = Me.TextBox2 End Sub Private Sub CommandButton1_Click() If Not oTextBox Is Nothing Then MsgBox oTextBox.Name End If End Sub