View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Variable Declaration

Any time I declare a variant I always specify it as being variant. It just
tells the user that I actually thought about it and have made the conscious
decision to have a variant.

All too often I see something like
Dim x
where the coder just didn't take the time to specify the type even though as
you read through the code it becomes obvious what the type should have been.

Sometimes I even spell Variant correctly but it you never bother to declare
your variable as being of type variant I guess it doesn't matter... ;-) And I
am the last person who should be complaingin about typo's in thos forum...
--
HTH...

Jim Thomlinson


"Bob Phillips" wrote:

Why would it, should it, say As Varaint, that is sloppy programming.

The % is short notation for As Integer, but it is a bit old hat, and not
really a good practice.

--
__________________________________
HTH

Bob

"Susan" wrote in message
...
why doesn't it say

Dim NewVar as Variant

& what's the percentage sign for?

:)
not-a-newbie-but-never-seen-this!
susan


On Jun 16, 12:45 pm, "greg" wrote:
it is displaying or demonstrating,
how to create a variable. in this case a variant.
put a value to it.
and display it in a message box

"R Tanner" wrote in message

...



Hi,


I'm reading a book learning how to program and I'm walking through an
example talking about variable declaration. I understand what the
following procedure is doing, but I don't understand what the purpose
of it is. Can anyone help me to understand why I would do this?


Sub Create_Var()


Dim NewVar%
NewVar = "45"
MsgBox (NewVar)


End Sub


Thanks,- Hide quoted text -


- Show quoted text -