在 VBScript 中使用变量索引数组时类型不匹配(工作表相关)



我在使用与Excel相关的VBScript时遇到了一些问题。我知道可能有一个直接的解决方案,稍后看起来很明显,但无论如何:

我在这里要实现的基本上是获取每列中最长值的长度并将它们写回数组(前 16 列中的每一列一个值(。就这么简单。

...
mlen = Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
For i = 1 To 16
  rw2 = 2                        ' starting from the second row
  While Cells(rw2, i) <> ""      ' all the way until an empty field is found
    If Len(Cells(rw2, i)) > mlen(i - 1) Then mlen(i - 1) = Len(Cells(rw2, i))
    rw2 = rw2 + 1
  Wend
Next
...

但是,它给了我">"运算符右侧的"mlen(i-1("的类型不匹配。

任何解决方案将不胜感激。提前感谢,祝你有美好的一天!

tmax <> mlen!

>> mlen = Array(0, 0, 0)
>> WScript.Echo mlen(0)
>> WScript.Echo tmax(0)
>>
0
Error Number:       13
Error Description:  Typenkonflikt (i.e. type-mismatch)
>>

相关内容

最新更新