link | convert | string//-----------searched by Asphouse http://aspage.yeah.net/--------------//
-----------from http://line9.com/tek9.asp?pg=freebies&specific=34-----//
Code title:auto-linking
Description:how would to have every instance of a http://auto-hyperlink to the URL
Address that follows it? We are a killer little function that would take every one of those that it
Finds in a string and sets up the hyperlink for you! Cool, eh?
Copy and paste this snippet As-is into your editor:
-------------------------------------------------------------------------
<%
Function Linkurls (strinput)
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&" ">" &strLinkText& "</a>"
Icurrentlocation = Ilinkend
Loop
Stroutput = stroutput & Mid (strinput, icurrentlocation)
Linkurls = Stroutput
End Function
strunlinked = "Http://LINE9.com rules! <br> "& VbCrLf
strunlinked = strunlinked & "Http://pdxpc.com sells great computers!<br>" & VbCrLf
' Here is the before text:
Response.Write "<b>original text:</b><br>" & vbCrLf
Response.Write strunlinked
Response.Write VbCrLf & "<br>" & VbCrLf & VbCrLf
' Here's the text after it gets automatically hyperlinked to itself:
Response.Write "<b>text after Linking:</b><br>" & VbCrLf
Response.Write Linkurls (strunlinked)
%>
-------------------------------------------------------------------------