gpt4 book ai didi

arrays - VBA 数组 : "Testarray(10)" – What are the initial values of this *without* assigning *any* value to *any* cell?

转载 作者:行者123 更新时间:2023-12-04 21:58:01 28 4
gpt4 key购买 nike

当我在 VBA 中编程时,我想将一个数组初始化为

Dim Testarray(10) As String

现在:不用多说,这个数组的初始值是多少?

或者换个方式问:我想用这个 Testarray为了找出某些值。然后将这些特定值更改为 "Missing Line"或任何东西。这样,我可以稍后检查所有数组值,以便通过通过相应的数组来查找我的缺失值的数量,例如 for。 -loop 或类似的东西。

( 额外问题: 现在,我正在学习如何编写 VBA 代码。数组是否总是必须有一个以 大写 字母开头的名称?或者也允许它开始用小写字母吗?)

最佳答案

String 的默认值是 vbNullString .

该常数的计算结果为 ""在比较中,"" 之间的区别和 vbNullString seems to be very small and pertaining mostly to memory economics on a tiny scale .

举个例子:

Sub test()
Dim Testarray(10) As String

Debug.Print Testarray(1) = ""
Debug.Print Testarray(1) = vbNullString
End Sub

输出:
True
True

关于arrays - VBA 数组 : "Testarray(10)" – What are the initial values of this *without* assigning *any* value to *any* cell?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40486667/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com