Here is something I wrote for a friend of mine and I figured I would share it. This code snippet will highlight most controls when they receive the focus. It can be further customized. See attached image.
Here is the code:
VB Code:
Option Explicit
'In a Module
Public Sub GotFocusFunct(ByVal NameObj As Object, _
Public Sub LostFocusFunct(ByVal NameObj As Object, _
ByVal lngIndex As Long, _
ByVal ShapeObj As Shape)
With NameObj.Item(lngIndex)
ShapeObj.Visible = False
.BackColor = vbWhite
End With
End Sub
and then you put the following code in the GotFocus and LostFocus Events:
VB Code:
Option Explicit
'On the Form
Private Sub Text1_GotFocus(Index As Integer)
Call GotFocusFunct(Text1, Index, Shape1)
End Sub
Private Sub Text1_LostFocus(Index As Integer)
Call LostFocusFunct(Text1, Index, Shape1)
End Sub
Note each control that you use this code with has to have a value entered into it Index property in order for this code to work. It works great with Control Arrays. Additionally, you must add a Shape1 rectangle object to the form.
Last edited by Mark Gambo; Sep 13th, 2005 at 06:50 PM.
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
Yeah this code can be expanded to do almost anything. Nice code BTW.
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."