There's a good example in the VBA Help.
Static applies to variables, not to Functions.
--
Tim Williams
Palo Alto, CA
"Brite" <(E-Mail Removed)> wrote in message news:F50A3D38-8DED-453F-BBFB-(E-Mail Removed)...
> I'm not sure if i'm doing something that doesn't work, but why can't i seem
> to get a static function to work the same as a static sub.
>
> If i run the following code a few times, and i always use the number 1 as x,
> i would think that the function should retain the previous value of "test",
> and then just increment it by 1, but this isn't happening. "Test" always
> returns as 1. I want this to work as a counter that other subs will pull from.
>
> Static Function test(x As Integer) As Integer
> test = test + x
> End Function
>
>
> thanks
|