将VBA代码转换为VB.net
我需要在VS2010中将这些VBA代码转换为VB.Net。我已经更改了其中一些,但VisualStudio会弹出错误消息。你能让我见识见识见识见识吗?谢谢将VBA代码转换为VB.net,vb.net,Vb.net,我需要在VS2010中将这些VBA代码转换为VB.Net。我已经更改了其中一些,但VisualStudio会弹出错误消息。你能让我见识见识见识见识吗?谢谢 Public Function enc(strWord) As String Dim l , x As Integer Dim charA As String strPW = "aaaaaaardewbacimnkiolujpgvdrytfd" l = Len(strPW) For x = 1
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
使用Convert.ToInt32,您试图将字符串(“a”)转换为整数。您想改用Microsoft.VisualBasic.Asc。错误消息肯定不是随机的!也许您可以通过告诉我们它们是什么以及它们在哪里来帮助我们您的代码编译。错误是什么?System.FormatException未经处理消息=输入字符串的格式不正确。StackTrace:System.Number.StringtNumber(String str、NumberStyles选项、NumberBuffer&Number、NumberFormatInfo信息、布尔parseDecimal)System.Number.ParseInt32(String s、NumberStyles样式、NumberFormatInfo信息)System.Convert.ToInt32(String值)at Throwaway.Form1.enc(Object strWord)在c:\users\documents\visualstudio 2012\Projects\Throwaway\Throwaway\Form1.vb中:第14Dim行a=Convert.ToInt32(“a”)实际上是失败的