我真的很郁闷。声明重复。
代码如下:该源代码的最终目的是用来转换一个字符串变量。最终结果是将一个字符串转换成“1:********”这样的格式。真正套用该变量的只有程序后后那么一小段。一旦运行这个自定义变量时。提示当前范围内的声明重复,VB提示错误的地方就是红色文字的位置,开始的时候我把inputstr = "123456" 这一段放在Dim inputstr As String后面,结果软件提示实时错误424,要求对象。
Function EncodeUser(UserName As String) As String
If CheckUserEncode.Value Then
Dim outstr As String
Dim DicStr As String
DicStr = "9012345678abcdeABCDEFGHIJKLMNfghijklmnUVWXYZxyzuvwopqrstOPQRST"
Dim DicA() As String
ReDim DicA(Len(DicStr) - 1)
Dim ff As Long
For ff = 0 To Len(DicStr) - 1
DicA(ff) = Mid(DicStr, ff + 1, 1)
Next
Dim DicB(15) As Byte
DicB(0) = &H11
DicB(1) = &H34
DicB(2) = &HC9
DicB(3) = &H23
DicB(4) = &H75
DicB(5) = &H18
DicB(6) = &HD7
DicB(7) = &HE2
DicB(8) = &H12
DicB(9) = &H35
DicB(10) = &H29
DicB(11) = &H2B
DicB(12) = &HEC
DicB(13) = &HB6
DicB(14) = &H23
DicB(15) = &H19
'************************************************************************** '
inputstr = "123456"
Dim inputstr As String
inputstr = UserName
Dim InputStrArray() As String
ReDim InputStrArray(Len(inputstr) - 1)
Dim OutPutArray() As String
ReDim OutPutArray(500)
For ff = 0 To Len(inputstr) - 1
InputStrArray(ff) = Mid(inputstr, ff + 1, 1)
Next
Dim i As Long
i = 0
Dim j As Long
j = 0
Dim num4 As Long: num4 = &H25
Dim di As Long
Dim var2 As Long
Dim index As Long
Dim var3 As Long: var3 = 0
For i = 0 To Len(inputstr) - 1
For j = 0 To Len(DicStr) - 1
If InputStrArray(i) = DicA(j) Then
If i >= &H10 Then
di = DicB(i Mod &H10)
Else
di = DicB(i)
End If
var2 = num4 * 3
index = (((di Xor var2) Xor var3) + j) Mod &H3E
OutPutArray(i) = DicA(index)
var2 = index
num4 = num4 Xor (var2 + &H24D9)
End If
Next j
If OutPutArray(i) = "" Then
OutPutArray(i) = InputStrArray(i)
End If
var3 = var3 + 5
Next i
Dim kk As Long
For kk = 0 To UBound(OutPutArray)
If OutPutArray(kk) <> "" Then
outstr = outstr + OutPutArray(kk)
End If
Next
outstr = "1:" + outstr
EncodeUser = outstr
Else
EncodeUser = UserName
End If
End Function
Private Sub Command1_Click()
Text2.Text = EncodeUser(Text1.Text)
End Sub