В коде ошибка которую я не могу исправить...
- Код: Выделить всё
Dim MaskElement() As Byte, MyText() As Byte
Private Sub SplitMask(ByRef MaskAsString As String)
Cls
ReDim MaskElement(Len(MaskAsString) - 1)
For i = LBound(MaskElement) To UBound(MaskElement) Step 1
MaskElement(i) = Val(Replace(Replace(Replace(Replace(Replace(Replace(Mid(MaskAsString, i + 1, 1), "A", 10), "B", 11), "C", 12), "D", 13), "E", 14), "F", 15))
Print MaskElement(i)
Next i
End Sub
Private Function RemakeTextByMask(ByRef sString As String) As String ' тут ошибка
Dim g As Long, i As Long
SplitMask Text1.Text
ReDim MyText(Len(sString) - 1)
For i = LBound(MyText) To UBound(MyText) Step 1
MyText(i) = Asc(Mid(sString, i + 1, 1))
Next i
If UBound(MyText) > UBound(MaskElement) Then
For g = LBound(MyText) To UBound(MyText) + UBound(MaskElement) Step UBound(MaskElement)
For i = LBound(MaskElement) To UBound(MaskElement) Step 1
RemakeTextByMask = RemakeTextByMask & Chr(MyText(g + MaskElement(i)))
Next i
Next g
Else
For i = LBound(MaskElement) To UBound(MaskElement) Step 1
RemakeTextByMask = RemakeTextByMask & Chr(MyText(g + MaskElement(i)))
Next i
End If
End Function
Private Function RndSetMask() As String
Randomize
Do
j = Int(Rnd * 14 + 1)
If InStr(1, RndSetMask, Mid("0123456789ABCDEF", j, 1), vbTextCompare) = 0 Then RndSetMask = RndSetMask & Mid("0123456789ABCDEF", j, 1)
Loop While Len(RndSetMask) < 14
End Function
Private Sub Text1_DblClick()
Text1 = RndSetMask
SplitMask Text1.Text
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then SplitMask Text1.Text: KeyAscii = 0
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then Text3.Text = RemakeTextByMask(Text2.Text): KeyAscii = 0
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then Text2.Text = Text3.Text: Text3.Text = RemakeTextByMask(Text2.Text): KeyAscii = 0
End Sub
Ещё хорошо бы было если бы кто-нибудь написал функцию расшифровки