[AccessD] Type of Constant

Stuart McLachlan stuart at lexacorp.com.pg
Wed Jul 9 17:55:39 CDT 2008


It is actually a Variant of Type Integer (not Long).

VarType(OFN_SHOWHELP)) returns 2 (vbInteger)

<quote>
The Variant data type is automatically specified if you don't specify a data type when 
you declare a constant, variable, or argument. Variables declared as the Variant data 
type can contain string, date, time, Boolean, or numeric values, and can convert the 
values they contain automatically. Numeric Variant values require 16 bytes of 
memory (which is significant only in large procedures or complex modules) and they 
are slower to access than explicitly typed variables of any other type. You rarely use 
the Variant data type for a constant. String Variant values require 22 bytes of 
memory.
</quote>

Bottom line, you should always declare the Type of constants and variables.

If you want it to be a Long use:

Private Const OFN_SHOWHELP AS LONG = &H10



On 9 Jul 2008 at 11:01, Heenan, Lambert wrote:

> "&H" is just the VB/VBA prefix that specifies a hexadecimal constant. So the
> value is 10 hex (16 Dec) and the type is Long Integer.
> 
> Lambert 
> 
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Dan Waters
> Sent: Wednesday, July 09, 2008 11:24 AM
> To: 'Access Developers discussion and problem solving'
> Subject: [AccessD] Type of Constant
> 
> I have a constant defined like this:
> 
> Private Const OFN_SHOWHELP = &H10
> 
> Is &H10 a Long?  A Variant?
> 
> Dan
> 
> 
> 
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com





More information about the AccessD mailing list