Link to home
Start Free TrialLog in
Avatar of matthewkwp
matthewkwp

asked on

Got Focus/Lost Focus Procedure

A procedure that uses "Got Focus" and "Lost Focus".  It needs to get the "Property Name" and use that name as a variable to set the Font.Name=True (False on the Lost Focus)
Avatar of bharris1
bharris1

What EXACTLY are you looking for?  Explain in detail.
Avatar of matthewkwp

ASKER

I have a form with 12 text boxes on it.  When a person moves from one text box to another I want the font to change to Bold.  Like wise when the focus is lost, the font will go back to normal.  I want to do a procedure, not having to code each text box.  The idea is to treat the property name as a variable and change the font according to text.box name.
ASKER CERTIFIED SOLUTION
Avatar of bharris1
bharris1

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BHarris1's answer (He beat me to the 'Submit' button)  insists on you putting a lot of code.  Try my answer instead:
Instead of using the property name (which I don't think you can do) why don't you create a control array of text boxes.  Then there is a single got focus, and a single lost focus event.  You can then determine which box is losing or getting the focus, by getting the value of index.
Code would look like this.

Private Sub Text1_LostFocus(Index As Integer)
          Text1(Index).Font.Bold=false
End Sub

Private Sub Text1_GotFocus(Index As Integer)
          Text1(Index).Font.Bold=true
End Sub

Let me know if you have any questions.

:) D Perry
This would work great if the TextBoxes were in a control array.

Thank you both for your help.  At my level (or lack there of) bharris's works for me.  Sorry D Perry >:(, when you start getting into arrays it is beyond me at this point. Thanks D Perry for your time
BHarris1's answer (He beat me to the 'Submit' button)  insists on you putting a lot of code.  Try my answer instead:
Instead of using the property name (which I don't think you can do) why don't you create a control array of text boxes.  Then there is a single got focus, and a single lost focus event.  You can then determine which box is losing or getting the focus, by getting the value of index.
Code would look like this.

Private Sub Text1_LostFocus(Index As Integer)
          Text1(Index).Font.Bold=false
End Sub

Private Sub Text1_GotFocus(Index As Integer)
          Text1(Index).Font.Bold=true
End Sub

Let me know if you have any questions.

:) D Perry