我需要在VS 2010中将这些VBA代码转换为VB.Net。我已经更改了其中的一些,但Visual Studio会弹出错误消息。你可以告诉我这是一个新手吗?感谢
Public Function enc(strWord) As String
Dim l , x As Integer
Dim charA As String
strPW = "aaaaaaardewbacimnkiolujpgvdrytfd"
l = Len(strPW)
For x = 1 To Len(strWord)
charA = Asc(Mid$(strPW, (x Mod l) - l * ((x Mod l) = 0), 1))
Mid$(strWord, x, 1) = Chr$(Asc(Mid$(strWord, x, 1)) Xor charA)
Next
enc = strWord
End Function
我的代码,
Public Function enc(ByVal strWord) As String
Dim l, x As Integer
Dim charA As String
Dim strPW As String
strPW = "aaaaaaardewbacimnkiolujpgvdrytfd"
l = strPW.Length()
For x = 1 To strWord.Length()
charA = Convert.ToInt32(Mid(strPW, (x Mod l) - l * ((x Mod l) = 0), 1))
Mid(strWord, x, 1) = Convert.ToChar(Convert.ToInt32(Mid(strWord, x, 1)) Xor charA)
Next
enc = strWord
End Function
答案 0 :(得分:0)
使用Convert.ToInt32,您尝试将字符串(" a")转换为整数。您想要使用Microsoft.VisualBasic.Asc。