/ Published in: ASP
![](/img/icon_sav.png?v3)
this function formats a web address for use in a link
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
'This function returns a formatted version of the given web address function formatWebAddress(byval webAddress) webAddress = Replace(webAddress, " ", "")'remove all spaces if webAddress <> "" then newWebAddress = "*" & webAddress if inStr(newWebAddress, "http://") = 0 then 'if http:// is not in the web address firstDotPos = inStr(newWebAddress, ".") if firstDotPos <> 0 then 'there is at least one dot secondDotPos = inStr(firstDotPos + 1, newWebAddress, ".") if secondDotPos <> 0 then 'there are at least two dots thirdDotPos = 0 thirdDotPos = inStr(secondDotPos + 1, newWebAddress, ".") if thirdDotPos <> 0 then 'if there are more than two dots then it is treated as invalid webaddress = "" else 'only two dots meaning it's something like www.example.com webAddress = "http://" & webAddress & "/" end if else 'only one dot meaning it's something like example.com webAddress = "http://www." & webAddress & "/" end if else 'if there are no dots then it's not an address webAddress = "" end if else if inStrRev(newWebAddress, "/") <> len(newWebAddress) then webAddress = webAddress & "/" end if end if end if formatWebAddress = webAddress end function
Comments
![RSS Feed for Comments RSS Icon](/images/rss.png?v3)