How to hyperlink Email addresses and URLs?

Discussion in 'ASP .Net' started by Graeme, Sep 5, 2004.

  1. Graeme

    Graeme Guest

    Hi All

    I call this function to hyperlink typed URLs, but there must surely be a
    better way. What I would like is something better to 1) automatically
    hyperlink URLs when clicked, and 2) same for Email addresses. Must have been
    done many times before more efficiently than this. Please can someone help?

    Function LinkURLs(ByVal strInput) 'called from POST button_click
    Dim iCurrentLocation

    Dim iLinkStart

    Dim iLinkEnd

    Dim strLinkText

    Dim strOutput

    iCurrentLocation = 1

    Do While InStr(iCurrentLocation, strInput, "http://", 1) <> 0

    iLinkStart = InStr(iCurrentLocation, strInput, "http://", 1)

    iLinkEnd = InStr(iLinkStart, strInput, " ", 1)

    If iLinkEnd = 0 Then iLinkEnd = Len(strInput) + 1

    Select Case Mid(strInput, iLinkEnd - 1, 1)

    Case ".", "!", "?"

    iLinkEnd = iLinkEnd - 1

    End Select

    strOutput = strOutput & Mid(strInput, iCurrentLocation, iLinkStart -
    iCurrentLocation)

    strLinkText = Mid(strInput, iLinkStart, iLinkEnd - iLinkStart)

    strOutput = strOutput & "<A HREF=""" & strLinkText & """ target=""_blank"">"
    & strLinkText & "</A>"

    iCurrentLocation = iLinkEnd

    Loop

    strOutput = strOutput & Mid(strInput, iCurrentLocation)

    LinkURLs = strOutput

    End Function

    Thanks for your assistance
    Graeme
     
    Graeme, Sep 5, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kaidi
    Replies:
    5
    Views:
    513
    Andrew Thompson
    Jan 4, 2004
  2. namespace1
    Replies:
    3
    Views:
    950
  3. Nathan Sokalski

    Converting Relative URLs into Absolute URLs

    Nathan Sokalski, Aug 11, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    781
    Sriram Srivatsan
    Aug 12, 2008
  4. Adam Monsen

    JDBC URLs ...not really URLs?

    Adam Monsen, Feb 6, 2009, in forum: Java
    Replies:
    11
    Views:
    6,396
    Adam Monsen
    Feb 8, 2009
  5. Steve T.

    dynamic URLS convert to static URLS for search engines

    Steve T., Mar 1, 2004, in forum: ASP .Net Web Services
    Replies:
    7
    Views:
    326
    Steve T.
    Mar 4, 2004
Loading...

Share This Page