我写了一个函数
函数代了几个参数,函数体对参数改变之后怎样回传给主调函数?
我的函数如下:
Public Function EncOtds(ByRef tmpstr As String, ByRef len As Int32, ByRef gs As Int32) As Int32
Dim commkey As String = "dlvanda"
Dim keylen As Integer
Dim i As Int32 = 0, m As Int32 keylen = commkey.Length
'Print(keylen) For i = 0 To tmpstr.Length
m = gs + i
tmpstr.IndexOf(i) = (Asc(tmpstr.IndexOf(i)) + Asc(commkey.IndexOf(m Mod keylen))).ToString
Next Return (m + 1) Mod keylen
End Function
我要主调函数直到这个tmpstr的值,,该如何做?
谢谢!
函数代了几个参数,函数体对参数改变之后怎样回传给主调函数?
我的函数如下:
Public Function EncOtds(ByRef tmpstr As String, ByRef len As Int32, ByRef gs As Int32) As Int32
Dim commkey As String = "dlvanda"
Dim keylen As Integer
Dim i As Int32 = 0, m As Int32 keylen = commkey.Length
'Print(keylen) For i = 0 To tmpstr.Length
m = gs + i
tmpstr.IndexOf(i) = (Asc(tmpstr.IndexOf(i)) + Asc(commkey.IndexOf(m Mod keylen))).ToString
Next Return (m + 1) Mod keylen
End Function
我要主调函数直到这个tmpstr的值,,该如何做?
谢谢!
IndexOf是用来找字符的,不是拿来取字符的,你或者可以用String.Substring方法,或者用mid函数
mid(tmpstr,i+1,1) = (Asc(tmpstr.substring(i)) + Asc(commkey.substring(m Mod keylen))).ToString