Posted to microsoft.public.excel.programming
|
|
Defining variables
Ok. Thanks Mike
"Mike H" wrote:
AFAIK there's no way to do that in a single line, you must dim your variable
and can then define a value for it
Dim cnt As Integer
cnt = 6
Mike
"Pawan" wrote:
This is correct. Here by 0 I want to say any value. Means suppose if I want
to assign default value of 2 (or any other value) to my variable, then is
there any way to assign it when we declare the variable? We can assign it in
separate statement like cnt = 2, but I want to assign it I at the same time
we declare the variable.
Thank You
"Mike H" wrote:
Hi,
When you dim your variable by default it is set as nothing which for an
integer variable is the same as zero which can be demonstrated with this bit
of code
Dim cnt As Integer
MsgBox cnt + 10
If you try this you will find the message box displays 10 so cnt was zero
Mike
"Pawan" wrote:
Hi
I have few variables which have default value of 0. This value will change
during macro execution. Is there any way to declare 0 value to these
variables while defining those at the beginning of the code? Means when we
define variable as Dim cnt as integer, can I define 0 value there itself?
Thank You
|