Error passing 2 parameters into a sub

  • Thread starter Thread starter Ben
  • Start date Start date
B

Ben

I get this error
"compile error expected:="

This is what I am doing. Passing in 2 strings from a
function into a sub in the same module.

IE.

public function testFunction()
dim strA as string = "hi"
dim strB as string = "bye"

testSub(strA, strB)

end function


public sub testSub(tempStringA as string, tempStringB as
string)
'.... do stuff in here with the 2 input strings

end sub


so when I type in "testSub(strA, strB)" above the compiler
gives the error expected:= is required.


In VBA can you only pass in one variable? Because when I
do it works fine.

Thanks,
Ben
 
You can read the help files on how to create and call subroutines and
functions.
public function testFunction()
dim strA as string = "hi"
dim strB as string = "bye"

testSub(strA, strB)

end function

Not bad except for the illegal Dim commands in lines 2 and 3, and the
illegal parentheses in line 4. And the fact that the function does not
return anything: if you have had to create it to respond to a RunCode, it's
worth while documenting it in a comment, or simply not using the the macro
at all.

Try this

Dim strA as string
Dim strB as string

strA = "a"
strB = "b"

TestSub strA, strB


HTH


Tim F
 
Thanks that was it the parens around the function call. I
am a c++ programmer and getting my hands dirty with some
VBA.
 
Thanks that was it the parens around the function call. I
am a c++ programmer and getting my hands dirty with some
VBA.

What version of access are you using? I am not aware of any dialect of
Basic that allows

It might help at least to peruse the help files or a book on VB or VBA
methods...


Tim F
 
Back
Top