Hi,
Just in case anybody else needs it and in the interests of helping
other Rb’ers here is a rot13 function.
Function Rot13(stringToRot as string) as string
dim NewStr as string
dim charactVal, tempValue, i as integer
NewStr = “”
for i = 1 to len(stringToRot)
charactVal = asc(mid(stringToRot, i, 1))
if charactVal >= asc(”A”) and charactVal < = asc("Z") then
tempValue = charactVal+13
'now loop it if it is > “Z”
if tempValue > asc(”Z”) then
tempValue = tempValue - 26
end
NewStr = NewStr + CHR(tempValue)
elseif charactVal >= asc(”a”) and charactVal < = asc("z") then
tempValue = charactVal+13
'now loop it if it is > “z”
if tempValue > asc(”z”) then
tempValue = tempValue - 26
end
NewStr = NewStr + CHR(tempValue)
else
‘just use it as is
NewStr = NewStr + mid(stringToRot, i, 1)
end
next
return NewStr
Cheers,
Dr Gerard Hammond
Garvan Institute of Medical Research
Leave a Reply
You must be logged in to post a comment.