LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 829
Default Top-Level Domain

"Peter T" wrote:
Here's an alterntive approach

[....]
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


Or more simply:

Const table As String = _
".net,.com,.org,.co.uk," ' note comma at end

Function isValidDom(dom As Variant) As Long
isValidDom = InStr(table, "." & dom & ",")
End Function


Sub testit()
Dim key As Variant
For Each key In Array("org", "xxx")
If isValidDom(key) Then MsgBox key & " okay" _
Else MsgBox key & " bad"
Next
End Sub


I was trying to avoid the linear comparison of 300+ names. But on second
thought, an Instr solution is probably just as good.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set macro security level to 'low level' on opening a certain workbook. andreashermle Excel Programming 2 November 15th 10 06:33 AM
Procedure level array not recognised at module level Numskull Excel Programming 2 May 21st 08 01:52 PM
The Domain www.bestnewsletter.eu is now for selling. The Domain for OVER 600 Million People in Europe. TAKE a LOOK !!! Excel Programming 0 June 3rd 06 04:54 PM
The Domain www.bestnewsletter.eu is now for selling. The Domain for OVER 600 Million People in Europe. TAKE a LOOK !!! Excel Programming 0 June 3rd 06 04:54 PM
Why, when I create workbook-level name does it jump it to Sheet-level ? Charles Jordan Excel Programming 1 November 5th 03 08:43 PM


All times are GMT +1. The time now is 03:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"