CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2000
    Posts
    8

    Url link in a label

    How would you put a Url link, so the user can click on it and it takes them to the url of the link?


  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Url link in a label

    Karl Peterson has a good (free with code) usercontrol (called HyperLabel ?) for download on his site at http://www.mvps.org/vb - I think it comes with a sample project also.

    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

  3. #3
    Guest

    Re: Url link in a label

    i suppose if you want to do that, then you need more code with it:

    you have to have a way to check if the user is hooked up to the internet.
    the user must have a browser (IE 4, NE 4)

    you could, as a desperate attempt, open IE 4, use a SendKeys function to send the label to it, and then sendkeys enter...this is a last attempt

    you can find the codes for hooked up to the internet in www.vbcode.com - there are several of them.
    there is a code which you can see if a fileexists there too, it is vbhelper.




  4. #4
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Url link in a label

    A simple way of opening a browser window with a specified URL is as follows :


    '
    ' Place this declare in a BAS / CLS / FRM module as appropriate
    ' not forgetting to change public to private where required !
    '
    public Declare Function ShellExecute Lib "shell32.dll" _
    Alias "ShellExecuteA" (byval hwnd as Long, _
    byval lpOperation as string, byval lpFile as string, _
    byval lpParameters as string, byval lpDirectory as string, _
    byval nShowCmd as Long) as Long
    '
    '
    public Sub ExecuteLink(byval sLinkTo as string)
    '
    ' Execute the passed Link
    '
    on error resume next
    '
    Dim lRet as Long
    Dim lOldCursor as Long
    '
    lOldCursor = Screen.MousePointer
    '
    Screen.MousePointer = vbHourglass
    '
    lRet = ShellExecute(0, "open", sLinkTo, "", vbNull, SW_SHOWNORMAL)
    '
    If lRet >= 0 And lRet <= 0 then
    Screen.MousePointer = vbDefault
    MsgBox "error Opening Link to " & sLinkTo & vbCrLf & _
    vbCrLf & Err.LastDllError, , "ExecuteLink"
    End If
    Screen.MousePointer = vbDefault
    '
    End Sub




    This allows you to call the 'ExecuteLink' routine in ways such as :


    ExecuteLink "http://codeguru.developer.com/vb"
    '
    ' or
    '
    ExecuteLink "mailto:[email protected]"




    The MSDN has a huge article somewhere that shows how to detect what your default browser is (if any) and also how to detect if you are connected to the internet (can't remember the URL's off the top of my head though).


    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

  5. #5

    Re: Url link in a label

    I'm not putting anybody down in any way, but I love it when people post saying:
    "yeah, I know of something like that. I think it's called &*&^%, but I don't remember where I found it."

    Well, I think it's funny.


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

Featured