PDA

View Full Version : Solved: Wrong Argument Syntax



island17
06-22-2004, 01:32 PM
Hi all

I want to create a procedure and pass two arguments to it. I have done this in the past, but for some reason now I keep getting the same error message in the vba editor ( Compiler Error, Expected =). Below is just a macro I was using to debug this problem (not the actual macro I will us it in).
As always your help will be appreciated.
Thanks
russ

Dim HI As String
Dim gregg As String
gregg = vbCr & "Gregg"
HI = "Russell says Hello"
sayhi(hi, gregg)

End Sub

Private Sub sayHi(verbage As String, FAN As String)
MsgBox verbage & FAN
End Sub

Zack Barresse
06-22-2004, 02:23 PM
Hi Russ, welcome!

I'm not sure what your Private Sub is for, but for the first one you could change your syntax to something like this:


Sub testoosie()

Dim HI As String
Dim gregg As String
Dim sayhi As String
gregg = vbCr & "Gregg"
HI = "Russell says Hello"
sayhi = HI & gregg
MsgBox sayhi

End Sub

It works for me. You can call it from another sub like this:


Call testoosie


But if it's private, you've gotta call it from the same module, else I'd just take that private off of there. Does that help any?

TonyJollans
06-22-2004, 02:23 PM
Hi Russ,

Your problem is the syntax of the line

sayhi(hi, gregg)

It is a single element, not a complete statement. To call the function as you want you should not have the parentheses ..

sayhi hi, gregg

island17
06-22-2004, 02:59 PM
Tony
Thanks, that is exactly what I wanted. The procedure I am using requires 3 separate strings passed to it. I never realized I didn't need the parenthesis.
Now how do I mark this Solved.
and Thanks again.
island17 (Russ)

Anne Troy
06-22-2004, 03:08 PM
Hey, Russ. We even mark it solved for ya. :)
Way to go, Tony.