Results 1 to 6 of 6

Thread: Function to change back color for label control (solved)

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354

    Function to change back color for label control (solved)

    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:
    1. Private Sub txtWeekEnd_LostFocus(ByVal sender As Object, _
    2.         ByVal e As System.EventArgs) _
    3.         Handles txtWeekEnd.LostFocus
    4.  
    5.         lblWeekEnd.BackColor = WhiteSmoke
    6.         lblWeekEnd.ForeColor = Black
    7.  
    8.     End Sub
    9.  
    10.     Private Sub txtEntryPerson_GotFocus(ByVal sender As System.Object, _
    11.         ByVal e As System.EventArgs)
    12.  
    13.         lblEntryPerson.BackColor = Black
    14.         lblEntryPerson.ForeColor = White
    15.  
    16.     End Sub
    17.  
    18.     Private Sub txtEntryPerson_LostFocus(ByVal sender As System.Object, _
    19.         ByVal e As System.EventArgs)
    20.  
    21.         lblEntryPerson.BackColor = WhiteSmoke
    22.         lblEntryPerson.ForeColor = Black
    23.  
    24.     End Sub
    25.  
    26.     Private Sub txtJobNumber_GotFocus(ByVal sender As Object, _
    27.         ByVal e As System.EventArgs) _
    28.         Handles txtJobNumber.GotFocus
    29.  
    30.         lblJobNumber.BackColor = Black
    31.         lblJobNumber.ForeColor = White
    32.  
    33.     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).
    Last edited by BukHix; Dec 17th, 2003 at 02:40 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width