Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default "!" at end of variable

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default "!" at end of variable

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default "!" at end of variable

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default "!" at end of variable

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default "!" at end of variable

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default "!" at end of variable

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default "!" at end of variable

# 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
"Type mismatch" when I try to fill an Array variable with "+" [email protected] Excel Discussion (Misc queries) 1 April 17th 07 01:28 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
reading variable "from" and "to" ZIP codes Dan Wasser[_2_] Excel Programming 2 January 9th 04 01:36 PM


All times are GMT +1. The time now is 02:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"