J
JoeU2004
The function below works as intended.
However, I get a syntax error when I try to replace "Set re =
CreateObject..." with
Set re = New regexp
and when I try to eschew the Set statement altogether and replace "Dim re"
with
Dim re as New regexp
The syntax error is "user-defined type not define".
Both erroneous forms appear in the examples at
http://msdn.microsoft.com/en-us/library/ms974570.aspx .
Why don't the examples?
I suspect I need to attach a reference (Tools > References). If so, which
reference?
Alternatively, are the examples written for an incompatible revision of
Excel/VB? If so, which one?
I am using Excel 2003 with VB 6.3 as part of Office 2003 and Win XP SP3.
Is the function, as written below, compatible with the VB with Excel 2007?
The function....
Function extractNumber(s As String, n As Integer)
Dim re, nums
extractNumber = ""
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "\d+"
Set nums = re.Execute(s)
If nums.Count >= n Then extractNumber = --nums.Item(n - 1)
End Function
However, I get a syntax error when I try to replace "Set re =
CreateObject..." with
Set re = New regexp
and when I try to eschew the Set statement altogether and replace "Dim re"
with
Dim re as New regexp
The syntax error is "user-defined type not define".
Both erroneous forms appear in the examples at
http://msdn.microsoft.com/en-us/library/ms974570.aspx .
Why don't the examples?
I suspect I need to attach a reference (Tools > References). If so, which
reference?
Alternatively, are the examples written for an incompatible revision of
Excel/VB? If so, which one?
I am using Excel 2003 with VB 6.3 as part of Office 2003 and Win XP SP3.
Is the function, as written below, compatible with the VB with Excel 2007?
The function....
Function extractNumber(s As String, n As Integer)
Dim re, nums
extractNumber = ""
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "\d+"
Set nums = re.Execute(s)
If nums.Count >= n Then extractNumber = --nums.Item(n - 1)
End Function