Article ID: 191713 - Last Review: June 29, 2004 - Revision: 4.0

INFO: Type Declaration Character to Data Type Chart

This article was previously published under Q191713
Expand all | Collapse all

SUMMARY

This article shows you the type declaration characters and corresponding data types. A Type Declaration Character is a character appended to a variable name indicating the variable's data type. For example, the variable name MyString$ has a dollar sign appended to the variable name and is dimensioned as a String data type.

MORE INFORMATION

The following table shows the type declaration characters and corresponding data types.
Type Declaration Character  Data Type
--------------------------  ---------
<WWBLOCKQUOTE>
          %                 Integer
          &                 Long
          !                 Single
          #                 Double
          $                 String
          @                 Currency
				
Even when using type declaration characters, you still need to declare your variables when you have Option Explicit at the beginning of the Module. Using Option Explicit is recommended to prevent problems due to misspelled variable names. When "Require Variable Declaration" is checked in the Editor Tab of the Options dialog box from the Tools Menu, Option Explicit is added to new Modules automatically. If you use Option Explicit, but you do not declare your variables, you will receive the following error message at run-time:
Compile Error
Variable Not Defined
To prevent this error from occurring, you can either remove Option Explicit or explicitly declare your variables. Using type declaration characters allows you to shorten these statements. For example, you can use this:
   Dim MyVar$
				
instead of this:
   Dim MyVar As String
				
Both statements declare MyVar to be a memory variable of type String.

APPLIES TO
  • Microsoft Visual Basic 6.0 Learning Edition
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 6.0 Enterprise Edition
  • Microsoft Visual Basic 5.0 Control Creation Edition
  • Microsoft Visual Basic 5.0 Learning Edition
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 4.0 Standard Edition
  • Microsoft Visual Basic 4.0 Professional Edition
  • Microsoft Visual Basic 4.0 16-bit Enterprise Edition
  • Microsoft Visual Basic 4.0 32-Bit Enterprise Edition
Keywords: 
kbinfo KB191713
 

Article Translations