0

我正在尝试将两个属性连接到一个字符串中,如下所示:

public class thing 
    public property word() as string()
    public property count() as integer()
end class

Public class myApp
    dim a_thing as new thing
    redim a_thing.word(upperBnd)
    redim a_thing.count(upperBnd)

    'I go on to fill the a_thing.word and .count arrays
    'Then I try to display the results...but it doesnt work.
    for i=0 to a_thing.word.length-1
        debug.writeline("Word: " & a_thing.word(i) & "  Count: " & a_thing.count(i))
    next
end class

for 语句只显示:

Word: [the_word_in_the_array] Word: [the_word_in_the_next_index] ...etc,         

没有新线...

如果我把它变成两个 debug.writeline 语句,我得到:

Word: [the_word_in_the_array] Count: [the_count_in_the_array]

这就是我想要的,但它在调试输出中无济于事......我需要将它放入单个字符串中。我试过使用 a_thing.count(i).tostring,但它不起作用。如果我单独查看数组,它们正是我想要的内容。但我无法连接它们。这里发生了什么?它是否与抑制 debug.writeline 通常创建的新行有关?

4

1 回答 1

0

检查 Word 数组中单词的末尾是否有 Null 字符。这会导致你看到的行为

于 2012-06-14T02:41:26.843 回答