Jan 19, 2003 #1 docrosen Programmer Jan 19, 2003 2 US Is there a way to capture in code, using VB6, which control on the form currently has focus?
Jan 19, 2003 1 #2 HobbitK Technical User Jan 14, 2003 235 US Docrosen, This assigns the name property of the control to a label Label1.Caption = Me.ActiveControl.Name Michael Upvote 0 Downvote
Docrosen, This assigns the name property of the control to a label Label1.Caption = Me.ActiveControl.Name Michael
Jan 19, 2003 1 #3 Digimon02 Programmer Dec 10, 2002 37 PH the most basic way is to use the GotFocus of the controls.. Declare a module level variable which where you will store the name of the control. Set the name of the control in this variable in GotFocus event of all the controls. Use this variable to know which control has the focus Ex. Private mCtlName as string Private Sub Command1_GotFocus() mCtlName = Command1.Name End Sub Private Sub Command2_GotFocus() mCtlName = Command2.Name End Sub Private Sub Text1_GotFocus() mCtlName = Text1.Name End Sub Private Sub Form_Unload(Cancel As Integer) MsgBox mctlName & " has the focus." End Sub Hope this solve your problem... Upvote 0 Downvote
the most basic way is to use the GotFocus of the controls.. Declare a module level variable which where you will store the name of the control. Set the name of the control in this variable in GotFocus event of all the controls. Use this variable to know which control has the focus Ex. Private mCtlName as string Private Sub Command1_GotFocus() mCtlName = Command1.Name End Sub Private Sub Command2_GotFocus() mCtlName = Command2.Name End Sub Private Sub Text1_GotFocus() mCtlName = Text1.Name End Sub Private Sub Form_Unload(Cancel As Integer) MsgBox mctlName & " has the focus." End Sub Hope this solve your problem...