View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tim Williams Tim Williams is offline
external usenet poster
 
Posts: 1,588
Default Stattic Variable

Always the same start number?

Tim

Sub dostatic()

Const X_START As Integer = 5
Static x As Integer

If x = 0 Then x = X_START

MsgBox x
x = x + 1
End Sub

"Lee" wrote in message
...

<<sorry. Shld have posted my message here instead of the
General section

Hi! Friends.

Can someone help:

I wish to preserve the value of a variable (say n) each
time I run the procedure, I have:

Sub count()
Static n as integer

n=n+1

end sub

May I know how I can start with an initial value of n
other than 0. I use CALL sub, but doesnt work.

Many thanks.
.