我目前正在编写一个需要从Magtek读卡器读取加密卡数据并将其发送到WS进行解密的功能。我从网站下载了阅读器的源代码,它在VB6上运行正常,但是我需要将它放到Visual Studio 2010上。这是VB6版本的代码:
If nValueNameLen > 0 Then
ReDim Preserve Values(0 To 1, 0 To nStrings) As String
Values(0, nStrings) = Left$(ValueName, nValueNameLen)
Values(1, nStrings) = Left$(Value, nValueLen - 1)
nStrings = nStrings + 1
End If
当我在2005年或2010年运行它来更新它时,代码如下所示:
If nValueNameLen > 0 Then
ReDim Preserve Values(1, nStrings)
Values(0, nStrings) = Left(ValueName, nValueNameLen)
Values(1, nStrings) = Left(Value, nValueLen - 1)
nStrings = nStrings + 1
End If
这导致“'ReDim'无法更改数组的维数”错误,在尝试更新时产生的大量其他错误中。如果他们试图将读卡器实现到他们自己的程序中(当然是在VB.net中),我可以为此做一个修复,或者可以使用更多当前代码。
答案 0 :(得分:1)
值可能声明为:
Dim Values() as String
需要声明时:
Dim Values(,) as String