how do i have text as a HTML type link in VB?

I have a string that i want to be presented to the user like a HTML link

i.e. - its just a label - but i'd like it to be blue and underlined and when the user mouses over it - the cursor should change to t a hand - and then i should respond to the click event.

how would i do this in VB?
LVL 4
kenshawAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carl TawnSystems and Integration DeveloperCommented:
Well you could get a rough approximation by using the MouseMove events of the Label and Form to switch the Hyperlink formatting on and off:

  Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
      Label1.Font.Underline = False
      Label1.ForeColor = vbBlack
  End Sub

  Private Sub Label1_Click()
      MsgBox "Link clicked"
  End Sub

  Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
      Label1.Font.Underline = True
      Label1.ForeColor = vbBlue
  End Sub


Hope this helps.
AtanAsfalothCommented:
If the label caption is the site the label should link to, you can open the webpage by:

Private Sub Label1_Click()
    Shell "explorer " & Label1.Caption
End Sub
AtanAsfalothCommented:
Hmm, and this code incluiding the 'Hand Cursor' Part



'API Calls
Private Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long
Private Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long

'Hand Cursor Constant
Private Const IDC_HAND = 32649&

Dim lngHandCursorHandle As Long

Private Sub Form_Load()
    'Initialize hand cursor
    lngHandCursorHandle = LoadCursor(0, IDC_HAND)
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Label1.Font.Underline = False
    Label1.ForeColor = vbBlack
    Screen.MousePointer = vbDefault
End Sub

Private Sub Label1_Click()
    Shell "explorer " & Label1.Caption
End Sub

Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim lngHandle As Long
    Label1.Font.Underline = True
    Label1.ForeColor = vbBlue
    SetCursor lngHandCursorHandle
End Sub



Atan Asfaloth

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vkaniCommented:
Hi kensaw!
try the following code:

Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.MousePointer = 99
Me.MouseIcon = LoadPicture(App.PATH & "\HARROW.CUR")
End Sub

copy the cursor file to app.path and try this!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.