VBA语言规范之变量初始值/默认值(Initial/Default Data Value - VBA Language Speficication)

变量初始值与变量声明类型直接相关,再次说明了数据类型的重要性和基础性。

变量声明类型
Declared Type

初始值/默认值
Initial Data Value

Boolean

FALSE

Byte, Currency, Double, Integer, Long, LongLong

0 value of the corresponding value type (section 2.1)

Double or Single

+0.0 value of the corresponding value type

Date

30 December 1899 00:00:00

String

The empty string

Variant

Empty

String*n, where n is an integer between 1 and 65,535

A string of length n consisting entirely of the implementation dependent representation of the null character corresponding to Unicode codepoint U+0000.

Fixed size array whose declared element type is one of Boolean, Byte, Currency, Data, Double, Object, Single, String, or String*n

The array data value whose number of dimensions and bounds are identical with the array’s declared dimensions and bounds and whose every element is the default data value of the declared element type.

Fixed size array whose declared element type is Variant

The array value whose number of dimensions and bounds are identical with the array’s declared dimensions and bounds and whose every element is the value Empty.

Resizable array whose declared element type is one of Boolean, Byte, Currency, Data, Double, Object, Single, String, or String*n

An array value with no dimensions.

Resizable array whose declared element type is Variant

An array value with no dimensions.

Object or a Specific class name

The value Nothing.

Specific UDT name

The UDT data value for the named UDT type whose every named element has the default data value from this table that is appropriate for that element’s declared type.



猜你喜欢

转载自blog.csdn.net/hpdlzu80100/article/details/80664914