Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Dim
Hi. I'm getting familiar with code that someone else wrote, and ran across
something I have never seen before. What is the difference between: Dim Msg Dim Msg$ What does the $ do? Thanks! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Dim
that is a form of implicit typing
? typename(msg) Empty '<== means it is an uninitialized variant ? typename(msg1$) String so Dim msg ' declares it as variant Dim msg$ ' declares it as String Dim msg& ' declares it as Long Dim msg! 'declares it as Single Dim msg# 'declares it as double Dim msg% 'declares it as Integer -- Regards, Tom Ogilvy "Steph" wrote: Hi. I'm getting familiar with code that someone else wrote, and ran across something I have never seen before. What is the difference between: Dim Msg Dim Msg$ What does the $ do? Thanks! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Dim
So essentially it saves you a few keystrokes: Dim Msg$ is the same as Dim
Msg as String. Got it. Thanks Tom. "Tom Ogilvy" wrote in message ... that is a form of implicit typing ? typename(msg) Empty '<== means it is an uninitialized variant ? typename(msg1$) String so Dim msg ' declares it as variant Dim msg$ ' declares it as String Dim msg& ' declares it as Long Dim msg! 'declares it as Single Dim msg# 'declares it as double Dim msg% 'declares it as Integer -- Regards, Tom Ogilvy "Steph" wrote: Hi. I'm getting familiar with code that someone else wrote, and ran across something I have never seen before. What is the difference between: Dim Msg Dim Msg$ What does the $ do? Thanks! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Dim
Dim Msg
declares Msg as a variant. It can hold anything--numbers, text, objects... Dim Msg$ is the same as dim Msg as String That $ sign is one of the several type declaration character shortcuts. (I find them difficult to remember, so I don't use them.) # = Double % = Integer & = Long @ = Currency ! = single $ = string Steph wrote: Hi. I'm getting familiar with code that someone else wrote, and ran across something I have never seen before. What is the difference between: Dim Msg Dim Msg$ What does the $ do? Thanks! -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Dim
Hi, Steph. It's called a "type-declaration character". The $ defines the
variable as a string. Here's some more info: http://support.microsoft.com/kb/191713/en-us http://msdn2.microsoft.com/en-us/library/s9cz43ek.aspx "Steph" wrote in message ... Hi. I'm getting familiar with code that someone else wrote, and ran across something I have never seen before. What is the difference between: Dim Msg Dim Msg$ What does the $ do? Thanks! |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Dim
To further Tom's answer check out this link.
http://www.dailydoseofexcel.com/arch...on-efficiency/ It deals with a number of string functions such as Trim, Left, ... and explains the benefits of using Trim$ and Left$... -- HTH... Jim Thomlinson "Tom Ogilvy" wrote: that is a form of implicit typing ? typename(msg) Empty '<== means it is an uninitialized variant ? typename(msg1$) String so Dim msg ' declares it as variant Dim msg$ ' declares it as String Dim msg& ' declares it as Long Dim msg! 'declares it as Single Dim msg# 'declares it as double Dim msg% 'declares it as Integer -- Regards, Tom Ogilvy "Steph" wrote: Hi. I'm getting familiar with code that someone else wrote, and ran across something I have never seen before. What is the difference between: Dim Msg Dim Msg$ What does the $ do? Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|