试图解决“无效使用Null”的问题。在VBA
首先是快速代码段:
Dim GUID As String
Dim givenNames, familyName, preferredName, gender, comments, carer, medicareNumber, patientNumber As String
Dim dob As Variant
Dim deceased, resolved, consultNotes As Boolean
Dim age As Variant
givenNames = Null
familyName = Null
preferredName = Null
gender = Null
dob = Null
comments = Null
deceased = False
resolved = False
carer = Null
age = Null
consultNotes = False
patientNumber = Null ' This is where I get the error
知道为什么这个最后一个变量会绊倒吗?我已经将Null分配给了许多其他字符串而没有任何错误。
没有找到相关结果
已邀请:
3 个回复
徐百晴墓斜
这就是为什么只在一行上声明它们是有道理的。 (顺便说一句,应该注意的是,由于同样的原因,
也被输入为变体。)
械怒等
等的原因是你无意中将它们定义为Variant类型。它失败了
,因为你成功地将它定义为
,并且字符串不接受Null值。 在
语句中,
子句适用于列表中的每个单独变量,因此通过仅将其放在列表的末尾,您只将显式类型应用于最后列出的变量。隐式
适用于其他类型。
陈獭
的隐式类型的情况下遇到这个问题时,我能够使用在
语句列表末尾定义一个额外变量(如
)的工作。