View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Peter T[_5_] Peter T[_5_] is offline
external usenet poster
 
Posts: 84
Default Top-Level Domain

"Charlotte E." wrote in message
Yeah, that solution is a no-brainer :-)

But, I was hoping to avoid using the worksheet interface, and get af
full VBA solution...

Guess, I'll have to stick to my 'Select Case' function...


I'd have gone with joeu2004's suggestion but 317 select case!!!

Here's an alterntive approach

Sub test()
MsgBox IsValidTLD(".net")
' maybe ensure its prefixed with a dot
MsgBox IsValidTLD("co.uk")
' hmm, is .co.uk a top level name or is only .uk
End Sub

Function IsValidTLD(ByVal sTLD As String) As Boolean
Dim sNames As String
Dim arr, v
sTLD = LCase$(sTLD)
sNames = ".net,.com," & _
".org,.co.uk"
sNames = Replace(sNames, " ", "")

arr = Split(sNames, ",")
For Each v In arr
If v = sTLD Then
IsValidTLD = True
Exit Function
End If
Next
End Function

Regards,
Peter T