遍历VB6字典
我是一个非VB6的人,不幸继承了一个遗留的VB6/Classic ASP项目。有一个部分,其中许多条目被放入遍历VB6字典,vb6,asp-classic,dictionary,Vb6,Asp Classic,Dictionary,我是一个非VB6的人,不幸继承了一个遗留的VB6/Classic ASP项目。有一个部分,其中许多条目被放入字典中,我想看看它包含的所有内容。我试过这个(oParams是一本字典): 它返回: 对象不支持此属性或方法:438 使用Option Explicit,如何迭代VB6字典,以找出它包含的所有内容?字典上的枚举不是对象类型,您应该改用变量: Dim o As Variant Dim sDicTempAggr As String sDicTempAggr = "" For Each o I
字典中,我想看看它包含的所有内容。我试过这个(oParams
是一本字典):
它返回:
对象不支持此属性或方法:438
使用Option Explicit
,如何迭代VB6字典
,以找出它包含的所有内容?字典上的枚举不是对象
类型,您应该改用变量
:
Dim o As Variant
Dim sDicTempAggr As String
sDicTempAggr = ""
For Each o In oParams
sDicTempAggr = sDicTempAggr & ", " & oParams(o)
Next
此外,在For Each
中,如果更改为ForFor Each o In oParams,则返回的键不是字典成员,因此值为oParams(o)
。项可以直接使用oParams
,如果仍然有问题,请查看第二个循环以检查字典中的值类型
Dim oParams As New Dictionary
oParams.Add 1, "This"
oParams.Add 2, "That"
oParams.Add 3, "The other"
Dim key As Variant
Dim sDicTempAggr As String
Dim sTypes As String
For Each key In oParams.Keys
sDicTempAggr = sDicTempAggr & IIf(sDicTempAggr <> "", ",", "") & oParams(key)
Next key
For Each key In oParams.Keys
sTypes = sTypes & IIf(sTypes <> "", ",", "") & TypeName(oParams(key))
Next key
Dim oParams作为新字典
oParams.添加1,“此”
oParams.加上2,“那”
oParams.添加3,“另一个”
变暗键作为变量
Dim sDicTempAggr作为字符串
以字符串形式显示的暗样式
对于oParams中的每个键。键
sDicTempAggr=sDicTempAggr&IIf(sDicTempAggr“”、“、”)和运算放大器(键)
下一键
对于oParams中的每个键。键
sTypes=sTypes&IIf(sTypes“,”和“)&TypeName(oParams(键))
下一键
Dim oParams As New Dictionary
oParams.Add 1, "This"
oParams.Add 2, "That"
oParams.Add 3, "The other"
Dim key As Variant
Dim sDicTempAggr As String
Dim sTypes As String
For Each key In oParams.Keys
sDicTempAggr = sDicTempAggr & IIf(sDicTempAggr <> "", ",", "") & oParams(key)
Next key
For Each key In oParams.Keys
sTypes = sTypes & IIf(sTypes <> "", ",", "") & TypeName(oParams(key))
Next key