Results 1 to 5 of 5

Thread: Text In Label

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2003
    Posts
    42

    Text In Label

    Hi,

    I gotta quick question for you guys/gals. I have created a form and inside that form there are about 50 labels and right now when you click on that label a DOS prompt opens up and it does a certian task.


    Now what I would like to do is. When the user put the mouse over that label I would like the text in that label turn blue like as if it's a hyperlink. How can I go about doing this ?


    Thanks In Advance
    ScarEye

  2. #2
    Addicted Member Psychotic's Avatar
    Join Date
    May 2004
    Posts
    164
    you could always use the trusty mousemove feature.

    Private Sub Label1_MouseMove(...)
    label1.forecolor = vbblue
    End Sub

    But u would have to turn the colour to its original when u moved the mouse off it.
    -Psychotic-

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2003
    Posts
    42
    Psychotic,

    If you don't mind me asking, what would the code be
    to have it go back to it's orginal color when the mouse is moved ?

    Thanks
    ScarEye

  4. #4
    Addicted Member Psychotic's Avatar
    Join Date
    May 2004
    Posts
    164
    there could be a better way to do it but heres a quick example.....(I assumed u have a control array since u have roughly 50 labels on the form)

    VB Code:
    1. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    2. For X = 0 To 9
    3.     Label1(X).ForeColor = vbBlack
    4. Next X
    5. End Sub
    6.  
    7. Private Sub Label1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    8. Label1(Index).ForeColor = vbBlue
    9. End Sub

    edit:

    You could store the index of the one that got the mouse move in a variable and then when the user moves over somthing else such as the form, u could set only the label in the variable back to the original forecolor.
    -Psychotic-

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2003
    Posts
    42
    "(I assumed u have a control array since u have roughly 50 labels on the form)"



    You assumed correctly. And this code worked perfectly.



    Thank you very much.. =)


    ScarEye

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