Encryption | array | String public Function ary (str)
Dim A ()
Dim B ()
Dim lenstr ' string length
Dim I, j ' Loop variable
Dim Ouflag
LENSTR = Len (str)
If lenstr Mod 2 = 1 Then
' The length is singular
Ouflag = False
LENSTR = lenstr + 1
ReDim A (2, LENSTR/2)
A (2, LENSTR/2) = Chr (20) ' last Fill space
Else
' Length is even
ReDim A (2, LENSTR/2)
Ouflag = True
End If
ReDim B (LENSTR/2, 2)
For i = 1 to Lenstr
If I <= lenstr/2 Then
A (1, i) = Mid (str, I, 1)
Else
If Ouflag = True Then
A (2, I-LENSTR/2) = Mid (str, I, 1)
Else
If I <> lenstr Then
A (2, I-LENSTR/2) = Mid (str, I, 1)
End If
End If
End If
Next
For i = 1 to 2
For j = 1 to LENSTR/2
B (J, I) = A (I, j)
Next
Next
For j = 1 to LENSTR/2
For i = 1 to 2
ary = ary & B (J, I)
Next
Next
If Ouflag = False Then
ary = left (ary, lenstr-1)
End If
End Function
Public Function unary (str)
Dim A ()
Dim B ()
Dim lenstr ' string length
Dim I, j ' Loop variable
Dim Ouflag
LENSTR = Len (str)
If lenstr Mod 2 = 1 Then
' The length is singular
Ouflag = False
LENSTR = lenstr + 1
ReDim A (LENSTR/2, 2)
A (LENSTR/2, 2) = CHR (20) ' last Fill space
Else
' Length is even
ReDim A (LENSTR/2, 2)
Ouflag = True
End If
ReDim B (2, LENSTR/2)
For i = 1 to Lenstr
If i = lenstr and Ouflag = False Then
A (LENSTR/2, 2) = ""
Else
If I Mod 2 = 1 Then
A ((i + 1)/2, 1) = Mid (str, I, 1)
Else
A (I/2, 2) = Mid (str, I, 1)
End If
End If
Next
For i = 1 to 2
For j = 1 to LENSTR/2
B (i, j) = A (j, i)
Next
Next
For i = 1 to 2
For j = 1 to LENSTR/2
unary = unary & B (i, J)
Next
Next
If Ouflag = Flag Then
unary = left (unary, lenstr-1)
End If
End Function
You'll know the use of it:
Dim Strg
Strg= "123456789"
Strg=ary (STRG)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.