Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assignment in VBA 3

Status
Not open for further replies.

jimbo08

Programmer
May 4, 2001
12
US
I am modifying someone else's code in an Access database. Can anyone explain the significance of the # in the following assignment:

Const TIER_EE As Double = 1#

Thanks
 
Percent or 1/100

Money can't buy happiness -- but somehow it's more comfortable to cry in a Corvette than in a Yugo.
 
For me, a trailing # indicates a DOUBLE var type.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya jimbo08 . . .
Microsoft said:
[blue]Double data type:
A data type that holds double-precision floating-point numbers as 64-bit numbers in the range -1.79769313486231E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values. The [purple]number sign[/purple] ([purple]#[/purple]) type-declaration character represents the Double in Visual Basic.[/blue]
Some of the others are:
[tt] [blue]![/blue] Single
[blue]@[/blue] Currency
[blue]&[/blue] Long
[blue]%[/blue] Integer
[blue]$[/blue] String[/tt]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
Thanks for the correction - all the legacy code we have with the # prints back as * .01; must be some formatting I missed somewhere!

Money can't buy happiness -- but somehow it's more comfortable to cry in a Corvette than in a Yugo.
 
Also I have seen several articles on avoiding TDCs

#4: Don't Use Type Declaration Characters

Most of Microsoft’s Basic variants offer the quaint (and archaic) type declaration character. By putting one of these pre-defined characters at the end of a variable or function name, you define the variable’s type or the function’s return value. For example, the following line of code:

Dim CName$
declares a variable called CName as a string. The dollar sign ($) character at the end is a type declaration character, and Access knows that a dollar sign signifies a string variable. The problem is that type declaration characters are old-fashioned. They still exist in VBA today primarily for backward compatibility. Good VBA code should avoid type declaration characters because they are considered obsolete. Also, there are only type declaration characters for a small subset of the data types that VBA supports.

You should also avoid the Def… statements, such as DefInt A-Z. These constructs are also obsolete, and can lead to code that is difficult to debug and maintain.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top