by alexK (9 Submissions)
Category: VB function enhancement
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Thu 4th February 2021
Rating: (1 Votes)
A function to rot13 a string
Function rot13(rot13text)
rot13text_rotated = ""
For i = 1 to Len(rot13text)
j = Mid(rot13text, i, 1)
k = Asc(j)
if k >= 97 and k =< 109 then
k = k + 13 ' a ... m inclusive become n ... z
elseif k >= 110 and k =< 122 then
k = k - 13 ' n ... z inclusive become a ... m
elseif k >= 65 and k =< 77 then
k = k + 13 ' A ... M inclusive become N ... Z
elseif k >= 78 and k =< 90 then
k = k - 13 ' N ... Z inclusive become A ... M
end if
rot13text_rotated = rot13text_rotated & Chr(k)
Next
rot13 = rot13text_rotated
End Function