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

本文详细介绍了不同数据类型的变量在声明时的初始值及其默认值,包括布尔型、整型、浮点型、日期型等常见类型及特定类型的默认值设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

变量声明类型
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.



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值