iLinkStart = InStr(iCurrentLocation, strInput, "http:">

转换字符串带有http://的超级链接字符串为真正的超级链接

80酷酷网    80kuku.com

  链接|转换|字符串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&""" target=""_blank"">"&strLinkText&"</a>"
iCurrentLocation = iLinkEnd
Loop
strOutput = strOutput & Mid(strInput, iCurrentLocation)
LinkURLs = strOutput
End Function

Dim strUnlinked
strUnlinked = "http://www.webjx.com http://www.163.com<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 is the text after it gets automatically hyperlinked to itself:
Response.Write "<b>Text After Linking:</b><br />" & vbCrLf
Response.Write LinkURLs(strUnlinked)

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: