URL Validation using VBA

T

travelerkgd

We're in need of generating some URL validation code with teh following
criteria:

1) User can enter URL without "http://"
2) Following the last period, for the ".com" or ."org" for example, we need
to make certain that this last part of teh URL is @ least two characters.
3) We need to make certain that when the admin enters a new URL into the
database (on our Backend), that URL is only entered once.

Thanks in advance.
 
B

Barry Gilbert

I can't guarantee that this will catch all bad urls:

Private Function IsItAUrl(byvalpUrl as String) As Boolean
Dim intDotPos As Integer
Dim intLastChars As Integer

intDotPos = InStrRev(pUrl, ".")
intLastChars = Len(Mid$(pUrl, intDotPos + 1, Len(pUrl)))
If intLastChars > 1 And intLastChars < 4 Then
IsItAUrl=True
End If
End Function

You can prevent duplicate URL's by putting a non-duplicate index on the field.

HTH,
Barry
 
T

travelerkgd

Thanks so much.
--
KGD


Barry Gilbert said:
I can't guarantee that this will catch all bad urls:

Private Function IsItAUrl(byvalpUrl as String) As Boolean
Dim intDotPos As Integer
Dim intLastChars As Integer

intDotPos = InStrRev(pUrl, ".")
intLastChars = Len(Mid$(pUrl, intDotPos + 1, Len(pUrl)))
If intLastChars > 1 And intLastChars < 4 Then
IsItAUrl=True
End If
End Function

You can prevent duplicate URL's by putting a non-duplicate index on the field.

HTH,
Barry
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top