I have a series of text boxes that the user tabs through. Right now have a lot of redundant code that I think I could put in one function if I knew how.
Basically what I have going on is that when a user is in a text control I reverse the colors on the label control for that text box. After the user leaves the text box its label goes back to the original color.
Here is a sample of the code I have now.
VB Code:
Private Sub txtWeekEnd_LostFocus(ByVal sender As Object, _ ByVal e As System.EventArgs) _ Handles txtWeekEnd.LostFocus lblWeekEnd.BackColor = WhiteSmoke lblWeekEnd.ForeColor = Black End Sub Private Sub txtEntryPerson_GotFocus(ByVal sender As System.Object, _ ByVal e As System.EventArgs) lblEntryPerson.BackColor = Black lblEntryPerson.ForeColor = White End Sub Private Sub txtEntryPerson_LostFocus(ByVal sender As System.Object, _ ByVal e As System.EventArgs) lblEntryPerson.BackColor = WhiteSmoke lblEntryPerson.ForeColor = Black End Sub Private Sub txtJobNumber_GotFocus(ByVal sender As Object, _ ByVal e As System.EventArgs) _ Handles txtJobNumber.GotFocus lblJobNumber.BackColor = Black lblJobNumber.ForeColor = White End Sub
How do I put that in a function to reduce the amount of code?
I kinda have an understanding of the use of functions but I am having some problem getting it to work for the current text box only (the calling text box).




Reply With Quote