Regular Expresions

Regular Expresions

Anonymous
Not applicable
233 Views
3 Replies
Message 1 of 4

Regular Expresions

Anonymous
Not applicable
This is probably a dumb question, but I'll ask it anyhow. Can you use
regular expressions in vba? I'd like to use something similar to the
following to verify a valid entry of a scale on a userform.

^[0-9]{1}=[0-9]{1}$|^[0-9]{1}=[0-9]{2}$|^[0-9]{1}=[0-9]{3}$

--
Tim Riley
0 Likes
234 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
yes,
add reference to Microsoft VBScript Regular Expressions 5.5

Set oRegExp = CreateObject("VBScript.RegExp")
oRegExp.IgnoreCase = True
oRegExp.Global = True
oRegExp.MultiLine = True
oRegExp.Pattern =
"^[0-9]{1}=[0-9]{1}$|^[0-9]{1}=[0-9]{2}$|^[0-9]{1}=[0-9]{3}$"

"Tim Riley" wrote in message
news:AE358EB0ACC74EC4387963D17D392760@in.WebX.maYIadrTaRb...
>
> This is probably a dumb question, but I'll ask it anyhow. Can you use
> regular expressions in vba? I'd like to use something similar to the
> following to verify a valid entry of a scale on a userform.
>
> ^[0-9]{1}=[0-9]{1}$|^[0-9]{1}=[0-9]{2}$|^[0-9]{1}=[0-9]{3}$
>
> --
> Tim Riley
>
>
0 Likes
Message 3 of 4

Anonymous
Not applicable
Awesome....Thank you.

--
Tim Riley



"Mark Propst" wrote in message
news:FB157CB5A2081F22855FA3109E1B5E9F@in.WebX.maYIadrTaRb...
> yes,
> add reference to Microsoft VBScript Regular Expressions 5.5
>
> Set oRegExp = CreateObject("VBScript.RegExp")
> oRegExp.IgnoreCase = True
> oRegExp.Global = True
> oRegExp.MultiLine = True
> oRegExp.Pattern =
> "^[0-9]{1}=[0-9]{1}$|^[0-9]{1}=[0-9]{2}$|^[0-9]{1}=[0-9]{3}$"
>
> "Tim Riley" wrote in message
> news:AE358EB0ACC74EC4387963D17D392760@in.WebX.maYIadrTaRb...
> >
> > This is probably a dumb question, but I'll ask it anyhow. Can you use
> > regular expressions in vba? I'd like to use something similar to the
> > following to verify a valid entry of a scale on a userform.
> >
> > ^[0-9]{1}=[0-9]{1}$|^[0-9]{1}=[0-9]{2}$|^[0-9]{1}=[0-9]{3}$
> >
> > --
> > Tim Riley
> >
> >
>
>
0 Likes
Message 4 of 4

Anonymous
Not applicable
I'll pass along the thanks to "ljb" who turned me on to regexp's
of course the settings:
> > oRegExp.IgnoreCase = True
> > oRegExp.Global = True
> > oRegExp.MultiLine = True
depend on what you want to do, they were just in the sample i cut and pasted
from

"Tim Riley" wrote in message
news:63EF9BF4CAC3AFFEA3D79AF2E6227BE4@in.WebX.maYIadrTaRb...
> Awesome....Thank you.
>
0 Likes