Click to See Complete Forum and Search --> : regular expressions in VB 6 - finally!


Lothar Haensler
October 28th, 1999, 03:53 AM
Folks, this needs some advertising. IE 5 comes with a COM component (microsoft VBScript regular expressions) that allows you to use regular expressions in VB!
I have been dealing with workarounds for this missing feature in VB since version 3.

how to use it

private Sub Command1_Click()
Dim r as new RegExp
r.Pattern = "\([0-9]{3}\)[0-9]+"
MsgBox r.Test(Text1.Text) ' pops up true or false
End Sub



this code checks text1 for a valid American phone number, e.g. (513)1234 (if that's the correct format).
This opens up a whole new bunch of cool tricks for input validation!

Ravi Kiran
October 28th, 1999, 04:05 AM
Cool...!! Nice find.
It is not allowing me to rate it - says "You have already rated this post!!".. though it is/was first time.. so i am saying it explicitely

RK