遍历 VB6 字典 [英] Iterate through a VB6 Dictionary

查看:48
本文介绍了遍历 VB6 字典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个非 VB6 的人,不幸继承了一个有缺陷的遗留 VB6/Classic ASP 项目.有一个部分将很多条目放入 Dictionary 中,我想查看它包含的所有内容.我试过这个(oParams 是字典):

I'm a non-VB6 person who had the misfortune of inheriting a buggy legacy VB6/Classic ASP project. There's a section where a lot of entries are put into a Dictionary and I want to see all it contains. I tried this (oParams is a Dictionary):

Dim o As Object
Dim sDicTempAggr As String
sDicTempAggr = ""
For Each o In oParams
    sDicTempAggr = sDicTempAggr & ", " & o
Next

返回:

对象不支持此属性或方法:438

Object doesn't support this property or method : 438

使用 Option Explicit,我如何遍历 VB6 Dictionary 以找出其中包含的所有内容?

Using Option Explicit, how do I iterate through a VB6 Dictionary to find out everything it contains?

推荐答案

这是一个迭代示例,如果您仍然有问题,请查看第二个循环以检查字典中值的类型

Here's a sample for iterating, if you still have a problem look at the second loop to inspect the types of the values in the dictionary

  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

这篇关于遍历 VB6 字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆