Home

VBA Data Types: Long

 

Introduction

A long integer is a number that can be used for a variable involving greater numbers than integers. To declare a variable that would hold such a large number, use the Long data type. Here is an example:

Sub Exercise()
    Dim Population As Long
End Sub

The type character for the Long data type is @. The above variable could be declared as:

Sub Exercise()
    Dim Population@
End Sub

A Long variable can store a value between – 2,147,483,648 and 2,147,483,647 (remember that the commas are used to make the numbers easy to read; do not be used them in your code). Therefore, after declaring a Long variable, you can assign it a number in that range.

To convert a value to a long integer, call CLng() using the following formula:

Number = CLng(Value to Convert)

To convert a value to long, enter it in the parentheses of CLng().

 
 
     
 

Home Copyright © 2009-2016, FunctionX, Inc.