0

我目前正在编写一个需要从 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 中),我可以为此做一个修复,还是可以使用任何更多的当前代码。

4

1 回答 1

1

值可能被声明为:

Dim Values() as String

什么时候需要声明:

Dim Values(,) as String
于 2013-07-25T22:44:49.660 回答