invalid procedure call or argument (error 5)

G

Guest

Hi there

I'm currently experiencing a problem with string comparison in VB ACCESS. Whenever I make an If Clause, the message of invalid procedure call or argument error will prompt. However, If compare with integer then it will pass. I can go though if I use the function strComp().
Just want to let you know I used my other computer that has the same version and libraries, and it works fine. Can you suggest what happenned there

Public Sub MySub(sProd As String
Dim s As Strin
Dim x As Intege
Dim varmsg As Varian
s = sPro
' this wor
varmsg = MsgBox(s

x = StrComp(sProd, "h/s"
If x = 0 The
varmsg = MsgBox("s"
End I
'this does not wor
If "s" = "s" The
varmsg = MsgBox(h
Els
varmsg = MsgBox(s
End I
'this wor
'If 1 = 1 The
' varmsg = MsgBox(s
'End I
End Sub
 
M

Marshall Barton

Antonio said:
I'm currently experiencing a problem with string comparison in VB ACCESS. Whenever I make an If Clause, the message of invalid procedure call or argument error will prompt. However, If compare with integer then it will pass. I can go though if I use the function strComp().
Just want to let you know I used my other computer that has the same version and libraries, and it works fine. Can you suggest what happenned there?

Public Sub MySub(sProd As String)
Dim s As String
Dim x As Integer
Dim varmsg As Variant
s = sProd
' this work
varmsg = MsgBox(s)

x = StrComp(sProd, "h/s")
If x = 0 Then
varmsg = MsgBox("s")
End If
'this does not work
If "s" = "s" Then
varmsg = MsgBox(h)
Else
varmsg = MsgBox(s)
End If
'this work
'If 1 = 1 Then
' varmsg = MsgBox(s)
'End If
End Sub


Did you compile that code?
Does the module have an Option Explicit near the top?
What line causes the error?

The only thing I can spot is that h is an undefined
variable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top