This is a simple utility, intended to sit on the desktop for when needed, that does the simple ROT13 encoding and decoding.
I am used to coding in VBA, and I am interested in more .Net idiomatic coding styles.
Public Class Rot13Decoder
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles txtRotEntry.TextChanged
lblResult.Text = Rot13(txtRotEntry.Text)
End Sub
Function Rot13(Source As String) As String
Dim i As Long
Dim result As String = ""
For i = 0 To Source.Length - 1
Dim myChar As Char
myChar = Source.Substring(i, 1)
Select Case myChar ' originally used Asc(Source(i)), hence the integers below
Case "a" To "m", "A" To "M" '65 To 77, 97 To 109
result &= Chr(Asc(myChar) + 13) 'Chr(Asc(Source(i)) + 13)
Case "n" To "z", "N" To "Z" '78 To 90, 110 To 122
result &= Chr(Asc(myChar) - 13) 'Chr(Asc(Source(i)) - 13)
Case Else
result &= myChar
End Select
Next
Return result
End Function
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
End Class
(The title of the form says decoder, and I am using it in the example to encode!)
Double clicking on the form result label copies the text to the clipboard for use.