我来自Perl的背景和学习Excel-VBA。在Perl中,我们可以使用Data :: Dumper来获取数据结构的转储。Excel VBA - 如何创建AND转储数组复杂结构的散列?
这里是perl的例子:
use strict;
use Data::Dumper;
my $hash={};
$hash->{key1} = [ 1, "b", "c" ]; # the value stored against key1 here is an array
$hash->{key2} = [ 4.56, "g", "2008-12-16 19:10 -08:00" ]; # the value stored against key2 here is an array
my $hash2={1=>['one','ONE']}; # this is a hash
$hash->{key3}=$hash2; # the value stored against key3 here is a hash
print Dumper($hash)."\n";
它产生以下的输出:
$VAR1 = {
'key2' => [
'4.56',
'g',
'2008-12-16 19:10 -08:00'
],
'key1' => [
1,
'b',
'c'
],
'key3' => {
'1' => [
'one',
'ONE'
]
}
};
正如我前面提到的,我是新来的Excel VBA和学习它,所以请大家多多包涵在帮助我达到以下问题的答案:
- 是否有类似perl的Data :: Dumper in Ex CEL-VBA?
- 如何使用Scripting.Dictionary对象在Excel-VBA中创建与上述结构完全相同的结构(即$ hash)?我如何迭代该结构并检索存储在键上的值?这种结构是否支持“存在”,“删除”,“添加”等等的方法?
你可以保持您的问题到一个具体点吗?这个问题需要多个响应。 – JustinJDavies 2013-02-25 08:19:27
这是一个与“Excel-VBA”相关的问题。我期待“Excel-VBA”本身的答案。 – 2013-02-25 08:47:44
我认为这里的主要问题是他来自一个Perl世界,其中'所有'问题都可以在oneliner中解决,但在vba中解决方案可能是10到100个代码链接,并且包含许多问题。 – FtLie 2013-02-25 11:41:34