Determine if a control got focus by Tab key or mouse click
' ----------------------------
' Constants & API Declarations
' ----------------------------
Declare Function GetKeyState% Lib "User" (ByVal nVirtKey%)
Const VK_TAB = 9
' -----------------
' Code
' -----------------
Sub Text1_GotFocus ()
If GetKeyState(VK_TAB) < 0 Then
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Else
Text1.SelLength = 0
End If
End Sub
Share:
These icons link to social bookmarking sites where readers can share and discover new web pages.
