View Full Version : Passing argument to a function


kirkm
12-13-2008, 06:56 PM
I've a crazy bug. Has it happened to anyone else and is there a reason for it?

Developing code, and all is fine. Then suddenly
--
Debug.Print l1 ' confirm it DOES exist
processL1(l1)
..
Sub processL1(ByVal l)
--
Variable l is *empty*.
This had been previously working fine.

I compile, run again - same problem.

I don't know what makes it come right, in this case I changed the code
to
--
Debug.Print l1
Call processL1(l1, "ddd") 'Add 'Call' & force a dummy variable to be passed

Sub processL1(ByVal l, z)
--

And everything is OK again. Other times I sort of muck about, adding test subs etc. until it starts working again.

Love to know what it is though.

Thanks - Kirk

WayneRyan
12-13-2008, 07:31 PM
Kirk,

See the help on the Call Statement:

Call SomeSub (a, b) <-- MUST have parentheses

Or

SomeSub a, b <-- Can Not have parentheses

Wayne

kirkm
12-13-2008, 11:43 PM
Thank you for that. Does it sometimes work though - this might explain the intermittency.