Array() 函数的行为是否发生了变化?
Has the behavior of the Array() function changed?
我在一些旧的 VB6 代码中遇到问题,这似乎与通过使用空参数列表调用 Array() 函数来创建空数组有关。
help for VBA表示这是合法的操作:
The required arglist argument is a comma-delimited list of values that
are assigned to the elements of the array contained within the
Variant. If no arguments are specified, an array of zero length is
created.
导致错误的函数的骨架如下所示。
该函数创建一个空数组,向该数组添加零个或多个元素,然后 return 将其发送给调用方。
在这种特殊情况下,它不会向数组添加任何元素,因此会尝试 return 一个空数组。
Private Function GetActiveRestrictionArray(ByVal Restrictions As String) As Variant
Dim Result As Variant
Result = Array()
'Do some stuff which might call "Redim"
'but in this case does not.
GetActiveRestrictionArray = Result
End Function
GetActiveRestrictionArray = Result 行现在生成错误 'Invalid procedure call or argument'.
用户报告说在 Windows 10 下执行 Windows 更新后出现此错误。同一用户报告说,如果他还原此更新,则错误消失。我不知道那是什么更新。
但是,我现在可以在虚拟机上的 VB6 中生成相同的错误 运行 Windows 7.
事实上,在 Result = Array() 行之后,如果我将鼠标悬停在变量 Result 上,它会显示消息 'Invalid procedure call or argument' 作为工具提示(在本例中为德语)。
老实说,我不知道这段代码是如何工作的,但显然是这样。
VB6 Array() 函数的行为是否可能发生了变化,特别是在使用空参数列表调用时?
这可能是由 Microsoft 的 2019 年 8 月补丁引起的。 MS 已经发布了一些额外的更新来解决 Windows.
的某些版本上的这个问题
参见:
https://docs.microsoft.com/en-us/windows/release-information/status-windows-10-1903#629msgdesc
https://support.microsoft.com/en-us/help/4512508/windows-10-update-kb4512508
https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2019-1182
后续更新:
Windows 7 x64: https://support.microsoft.com/en-us/help/4517297/windows-7-update-kb4517297
Windows 10 版本 1709: https://support.microsoft.com/en-us/help/4512494/windows-10-update-kb4512494
Windows 10 版本 1809: https://support.microsoft.com/en-us/help/4512534
我在一些旧的 VB6 代码中遇到问题,这似乎与通过使用空参数列表调用 Array() 函数来创建空数组有关。
help for VBA表示这是合法的操作:
The required arglist argument is a comma-delimited list of values that are assigned to the elements of the array contained within the Variant. If no arguments are specified, an array of zero length is created.
导致错误的函数的骨架如下所示。
该函数创建一个空数组,向该数组添加零个或多个元素,然后 return 将其发送给调用方。 在这种特殊情况下,它不会向数组添加任何元素,因此会尝试 return 一个空数组。
Private Function GetActiveRestrictionArray(ByVal Restrictions As String) As Variant
Dim Result As Variant
Result = Array()
'Do some stuff which might call "Redim"
'but in this case does not.
GetActiveRestrictionArray = Result
End Function
GetActiveRestrictionArray = Result 行现在生成错误 'Invalid procedure call or argument'.
用户报告说在 Windows 10 下执行 Windows 更新后出现此错误。同一用户报告说,如果他还原此更新,则错误消失。我不知道那是什么更新。
但是,我现在可以在虚拟机上的 VB6 中生成相同的错误 运行 Windows 7.
事实上,在 Result = Array() 行之后,如果我将鼠标悬停在变量 Result 上,它会显示消息 'Invalid procedure call or argument' 作为工具提示(在本例中为德语)。
老实说,我不知道这段代码是如何工作的,但显然是这样。
VB6 Array() 函数的行为是否可能发生了变化,特别是在使用空参数列表调用时?
这可能是由 Microsoft 的 2019 年 8 月补丁引起的。 MS 已经发布了一些额外的更新来解决 Windows.
的某些版本上的这个问题参见:
https://docs.microsoft.com/en-us/windows/release-information/status-windows-10-1903#629msgdesc
https://support.microsoft.com/en-us/help/4512508/windows-10-update-kb4512508
https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2019-1182
后续更新:
Windows 7 x64: https://support.microsoft.com/en-us/help/4517297/windows-7-update-kb4517297
Windows 10 版本 1709: https://support.microsoft.com/en-us/help/4512494/windows-10-update-kb4512494
Windows 10 版本 1809: https://support.microsoft.com/en-us/help/4512534