Home

VBA Data Types: Double

 
 

Introduction

If you want to use a decimal number that requires a good deal of precision, declare a variable using the Double data type. Here is an example of declaring a Double variable:

Sub Exercise()
    Dim Distance As Double
End Sub

Instead of As Double, the type character you can use is #:

Sub Exercise()
    Dim Distance#
End Sub

A Double variable can hold a number between –1.79769313486231e308 and
–4.94065645841247e–324 for negative values or between 4.94065645841247e–324 and  1.79769313486231e308 for positive values.

To convert a value to double-precision, you can call the CDbl() function:

Number = CDbl(Value to Convert)

In the parentheses of CDbl(), enter the value that needs to be converted.

 
 
     
 

Home Copyright © 2009-2016, FunctionX, Inc.