public function ary(str)
dim a()
dim b()
dim lenstr '字符串长
dim i, j '循环变量
dim ouflag
lenstr = len(str)
if lenstr mod 2 = 1 then
'长度为奇
ouflag = false
lenstr = lenstr + 1
redim a(2, lenstr / 2)
a(2, lenstr / 2) = chr(20) '最后一个补空格
else
'长度为偶
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 '字符串长
dim i, j '循环变量
dim ouflag
lenstr = len(str)
if lenstr mod 2 = 1 then
'长度为奇
ouflag = false
lenstr = lenstr + 1
redim a(lenstr / 2, 2)
a(lenstr / 2, 2) = chr(20) '最后一个补空格
else
'长度为偶
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
用了你就知道用处了:
dim strg
strg="123456789"
strg=ary(strg)
unary是解密