View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Andrew Taylor Andrew Taylor is offline
external usenet poster
 
Posts: 225
Default passing multiple strings to a function

Subs are called without enclosing the parameter list in parentheses
(which is probably what the error message was telling you), unless
you use the Call statement, so you need either:

TestSub testStr1, testStr2

or

Call TestSub(testStr1, testStr2)

Andrew Taylor


Tijmen wrote:
It seems that it is not possible to pass multiple string arguments to a
function in vba.
I am using vba in Excel 2000.
Why does this not work?

Dim testStr1
Dim testStr2

testStr1 = "hi"
testStr2 = "there"

' I get a compile error on the next statement
TestSub(testStr1, testStr2)


Sub TestSub(str1 as String, str2 as String)

MsgBox(str1 & str2)

End sub



Thanks,

Tijmen