通过VB6字典迭代 [英] Iterate through a VB6 Dictionary

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

问题描述

我是一个非VB6人谁了继承了传统越野车VB6 / ASP经典项目的不幸。还有的地方有很多条目被放入词典 A部分,我想看到​​它包含所有。我想这( 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

使用选项显式,我怎么通过VB6 词典找出一切它包含迭代?

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天全站免登陆