SeanNij
asked on
Application Object Error 5017
Hi all, hope all is well.
Question: Got two button on a form to validate the data entered. The first button works like a charm. Why do i get an Error 5017: Application-defined or object-defined error? on the second button (command8)
Private Sub Command6_Click()
Dim regularexpressionobject As Object
Set regularexpressionobject = New VBScript_RegExp_10.RegExp
With regularexpressionobject
.Pattern = "^(([a-zA-Z0-9\.\-_\&] +)([a-zA-Z 0-9]+)@([a -zA-Z0-9\- ]+)(\.[a-z A-Z0-9\-]+ ){1,6})$"
.IgnoreCase = True
.Global = True
End With
If regularexpressionobject.Te st(EmailAd dress.Valu e) Then
MsgBox "valid", vbOKOnly
Else
MsgBox "invalid", vbOKOnly
End If
End Sub
Private Sub Command8_Click()
Dim regularexpressionobject As Object
Set regularexpressionobject = New VBScript_RegExp_10.RegExp
With regularexpressionobject
.Pattern = "(?i)\bbox\ |post|private|\bpo\ |\bpobox|\bbag\ |p\.o$"
.IgnoreCase = True
.Global = True
End With
If regularexpressionobject.Te st(StreetA ddress.Val ue) Then
MsgBox "valid", vbOKOnly
Else
MsgBox "invalid", vbOKOnly
End If
End Sub
Thanks
Sean
Question: Got two button on a form to validate the data entered. The first button works like a charm. Why do i get an Error 5017: Application-defined or object-defined error? on the second button (command8)
Private Sub Command6_Click()
Dim regularexpressionobject As Object
Set regularexpressionobject = New VBScript_RegExp_10.RegExp
With regularexpressionobject
.Pattern = "^(([a-zA-Z0-9\.\-_\&]
.IgnoreCase = True
.Global = True
End With
If regularexpressionobject.Te
MsgBox "valid", vbOKOnly
Else
MsgBox "invalid", vbOKOnly
End If
End Sub
Private Sub Command8_Click()
Dim regularexpressionobject As Object
Set regularexpressionobject = New VBScript_RegExp_10.RegExp
With regularexpressionobject
.Pattern = "(?i)\bbox\ |post|private|\bpo\ |\bpobox|\bbag\ |p\.o$"
.IgnoreCase = True
.Global = True
End With
If regularexpressionobject.Te
MsgBox "valid", vbOKOnly
Else
MsgBox "invalid", vbOKOnly
End If
End Sub
Thanks
Sean
ASKER
Nope nothing missing. Keep in mind - both buttons are on the same form. Press the first one and it works - press the second one and i get that error?
try releasing the object variable { regularexpressionobject } after you use it
set regularexpressionobject=no thing
set regularexpressionobject=no
ASKER
Nope no luck.
Could it be something to do with the pattern - may an incorrect pattern stuff it up?
Could it be something to do with the pattern - may an incorrect pattern stuff it up?
try this
Private Sub Command6_Click()
Dim regularexpressionobject As Object
'Set regularexpressionobject = New VBScript_RegExp_10.RegExp
Set regularexpressionobject = CreateObject("VBScript.Reg
With regularexpressionobject
.Pattern = "^(([a-zA-Z0-9\.\-_\&]
.IgnoreCase = True
.Global = True
End With
If regularexpressionobject.Te
MsgBox "valid", vbOKOnly
Else
MsgBox "invalid", vbOKOnly
End If
Set regularexpressionobject = Nothing
End Sub
Private Sub Command8_Click()
Dim regularexpressionobject As Object
'Set regularexpressionobject = New VBScript_RegExp_10.RegExp
Set regularexpressionobject = CreateObject("VBScript.Reg
With regularexpressionobject
.Pattern = "(?i)\bbox\ |post|private|\bpo\ |\bpobox|\bbag\ |p\.o$"
.IgnoreCase = True
.Global = True
End With
If regularexpressionobject.Te
MsgBox "valid", vbOKOnly
Else
MsgBox "invalid", vbOKOnly
End If
Set regularexpressionobject = Nothing
End Sub
ASKER
Exactly same error msg.
btw, which line is higlighted?
ASKER
If regularexpressionobject.Te st(StreetA ddress.Val ue) Then
if i copy the pattern from the first button into the second set of code it works - can it be the pattern itself?
if i copy the pattern from the first button into the second set of code it works - can it be the pattern itself?
remove the .value
If regularexpressionobject.Te st(StreetA ddress) Then
how do you pass the StreetAddress?
If regularexpressionobject.Te
how do you pass the StreetAddress?
SeanNij,
it is the pattern that is giving you the error.
it is the pattern that is giving you the error.
try using this pattern
.Pattern = "^([a-zA-Z0-9\.\-_\&]) ([a-zA-Z0- 9]+)"
Private Sub Command8_Click()
Dim regularexpressionobject As Object
'Set regularexpressionobject = New VBScript_RegExp_10.RegExp
Set regularexpressionobject = CreateObject("VBScript.Reg Exp")
With regularexpressionobject
' .Pattern = "(?i)\bbox\ |post|private|\bpo\ |\bpobox|\bbag\ |p\.o$"
.Pattern = "^([a-zA-Z0-9\.\-_\&]) ([a-zA-Z0- 9]+)"
.IgnoreCase = True
.Global = True
End With
If regularexpressionobject.Te st(StreetA ddress.Val ue) Then
MsgBox "valid", vbOKOnly
Else
MsgBox "invalid", vbOKOnly
End If
Set regularexpressionobject = Nothing
End Sub
.Pattern = "^([a-zA-Z0-9\.\-_\&])
Private Sub Command8_Click()
Dim regularexpressionobject As Object
'Set regularexpressionobject = New VBScript_RegExp_10.RegExp
Set regularexpressionobject = CreateObject("VBScript.Reg
With regularexpressionobject
' .Pattern = "(?i)\bbox\ |post|private|\bpo\ |\bpobox|\bbag\ |p\.o$"
.Pattern = "^([a-zA-Z0-9\.\-_\&])
.IgnoreCase = True
.Global = True
End With
If regularexpressionobject.Te
MsgBox "valid", vbOKOnly
Else
MsgBox "invalid", vbOKOnly
End If
Set regularexpressionobject = Nothing
End Sub
ASKER
then it works.
however not allowing / disallowing what i need - so therefor the pattern line is wrong.
however not allowing / disallowing what i need - so therefor the pattern line is wrong.
SeanNij,
<so therefor the pattern line is wrong.>
wish i could see from the crystal ball what pattern you need
i can not guess what you need to filter,
<so therefor the pattern line is wrong.>
wish i could see from the crystal ball what pattern you need
i can not guess what you need to filter,
ASKER
and here i thought you would be able too...;)
I want to check that address lines may contain the phrase PO BOX/PRIVATE BAG/POST or any abbreviation there off.
Question: Do you ever sleep?
I want to check that address lines may contain the phrase PO BOX/PRIVATE BAG/POST or any abbreviation there off.
Question: Do you ever sleep?
I just woke up.
sean,
can you post some real data, of different variation.
sean,
can you post some real data, of different variation.
ASKER
CompanyName,StreetAddress, PostalAddr ess,City
Tarsus Networking (Pty) Ltd.,Prosperity Park Democracy Way Milnerton 7441,PO Box 19234,Vlaeberg
Bromor Foods (Pty) LTD,No 5 Sunrise Circle Ndabeni,PO Box 28,Cape Town
Trencor Ltd,PO Box 13160 Dowerglen Ext 7,1313 Main Tower, Heerengracht Street Standard Bank Centre, CT
USABCO,,PO Box 277,Bellville Boland Bank,333 Main Road Paarl",PO Box 4,Paarl
Tarsus Networking (Pty) Ltd.,Prosperity Park Democracy Way Milnerton 7441,PO Box 19234,Vlaeberg
Bromor Foods (Pty) LTD,No 5 Sunrise Circle Ndabeni,PO Box 28,Cape Town
Trencor Ltd,PO Box 13160 Dowerglen Ext 7,1313 Main Tower, Heerengracht Street Standard Bank Centre, CT
USABCO,,PO Box 277,Bellville Boland Bank,333 Main Road Paarl",PO Box 4,Paarl
this
.Pattern = "^([a-zA-Z0-9\.\-_\&()
pass the the top three sample, the last one failed due to the " in { Main Road Paarl",PO Box 4,Paarl } which i think is a wrong format
ASKER
But its this pattern i'm trying to get too work:
"(?i)\bbox\ |post|private|\bpo\ |\bpobox|\bbag\ |p\.o$"
"(?i)\bbox\ |post|private|\bpo\ |\bpobox|\bbag\ |p\.o$"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
YIPPEEEEE
what is the diff between ?i and i?
what is the diff between ?i and i?
? -- Matches 0 or 1 instances of preceding character
-------------------------- ---------- --------^^ ^^^^
--------------------------
Ctrl+G then Tools --> References. See if any are marked missing.