Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi-
I have the pleasure of fixing another's vba code and, having very little experience with vba myself, I had a question about variable names. From what I've read, vba variables shouldn't have !, &, %, etc. in the name. However, in this particular piece of code, there are some Dim statements declaring some variables with an "!" at the end. In the actual code, however, the "!" is left out. What is this all about? TIA! joak |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Joak,
Declaring a variable in this way is typing it at the same time. Dim a! is the same as Dim a As Single Dim a% is the same as Dim a As Integer. The variable though is just called a, so that is all you need to refer to it by in the code. Personally, I think it is ugly syntax, much better to declare the type clearly. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "joak" wrote in message ... Hi- I have the pleasure of fixing another's vba code and, having very little experience with vba myself, I had a question about variable names. From what I've read, vba variables shouldn't have !, &, %, etc. in the name. However, in this particular piece of code, there are some Dim statements declaring some variables with an "!" at the end. In the actual code, however, the "!" is left out. What is this all about? TIA! joak |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In article ,
"Bob Phillips" wrote: Personally, I think it is ugly syntax, much better to declare the type clearly. That, and whoever decided that the *percent* sign should indicate an *integer* should have been shot. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It's not part of the variable name, per se. It's a type declaration
character. ! indicates a Single, so Dim foo! is equivalent to Dim foo As Single Each data type (other than Variant and Object) has a type declaration character. You can see them in XL/VBA Help. In article , "joak" wrote: I have the pleasure of fixing another's vba code and, having very little experience with vba myself, I had a question about variable names. From what I've read, vba variables shouldn't have !, &, %, etc. in the name. However, in this particular piece of code, there are some Dim statements declaring some variables with an "!" at the end. In the actual code, however, the "!" is left out. What is this all about? TIA! |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Joak,
The '!' at the end of the variable name forces that variable to be of type Single. The '!' is a substitute for "As Single". Other type specification characters include $ As String # As Long @ As Currency % As Integer & As Long -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "joak" wrote in message ... Hi- I have the pleasure of fixing another's vba code and, having very little experience with vba myself, I had a question about variable names. From what I've read, vba variables shouldn't have !, &, %, etc. in the name. However, in this particular piece of code, there are some Dim statements declaring some variables with an "!" at the end. In the actual code, however, the "!" is left out. What is this all about? TIA! joak |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Chip, JE, and Bob-
Ah, I get it now. Thank you very much! You guys are great! Joak -----Original Message----- Joak, The '!' at the end of the variable name forces that variable to be of type Single. The '!' is a substitute for "As Single". Other type specification characters include $ As String # As Long @ As Currency % As Integer & As Long -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "joak" wrote in message ... Hi- I have the pleasure of fixing another's vba code and, having very little experience with vba myself, I had a question about variable names. From what I've read, vba variables shouldn't have !, &, %, etc. in the name. However, in this particular piece of code, there are some Dim statements declaring some variables with an "!" at the end. In the actual code, however, the "!" is left out. What is this all about? TIA! joak . |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
# As Long
This should, of course, be As Double. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Chip Pearson" wrote in message ... Joak, The '!' at the end of the variable name forces that variable to be of type Single. The '!' is a substitute for "As Single". Other type specification characters include $ As String # As Long @ As Currency % As Integer & As Long -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "joak" wrote in message ... Hi- I have the pleasure of fixing another's vba code and, having very little experience with vba myself, I had a question about variable names. From what I've read, vba variables shouldn't have !, &, %, etc. in the name. However, in this particular piece of code, there are some Dim statements declaring some variables with an "!" at the end. In the actual code, however, the "!" is left out. What is this all about? TIA! joak |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
"Type mismatch" when I try to fill an Array variable with "+" | Excel Discussion (Misc queries) | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel | |||
reading variable "from" and "to" ZIP codes | Excel Programming |