View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Marcus Schöneborn Marcus Schöneborn is offline
external usenet poster
 
Posts: 15
Default VBA - array or collection literals?

Currently, I have written a function to do some sort of pattern
matching:

Dim delims As New Collection
delims.Add " <"
delims.Add "@"
delims.Add ""

Dim tokens As Collection
tokens = UnDelimit("Marcus Schöneborn ", delims)
? tokens.Count ' 4
? tokens(1) ' "Marcus Schöneborn"
? tokens(2) ' "divZero"
? tokens(3) ' "googlemail.com"
? tokens(4) ' ""

Is there a simpler way to call this by making a "literal" collection,
think of it like

Dim tokens As Collection
tokens = UnDelimit("...", {" <", "@", ""})

Or is there a way to get C-like function varargs, so I can use it like

Dim tokens As Collection
tokens = UnDelimit("...", " <", "@", "")

Or, alternatively: is there a way to make the VBScript.RegExp object
support . matching newlines?