Public Class Tester
Public Shared Sub Main
Dim source As String = "Hello world!"
Dim characters As String = _
"~ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,:?'-/"""
Dim morse() As String = { _
"?", ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", _
"..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", _
"--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", _
"-.--", "--..", "-----", ".----", "..---", "...--", _
"....-", ".....", "-....", "--...", "---..", "----.", _
".-.-.-", "--..--", "---...", "..--..", ".----.", _
"-....-", "-..-.", ".-..-."}
Dim counter As Integer
Dim position As Integer
For counter = 0 To source.Length - 1
position = characters.IndexOf(Char.ToUpper( _
source.Chars(counter)))
If (position < 0) Then position = 0
Console.Write (source.Substring(counter, 1) & " ")
Console.WriteLine(morse(position))
Next counter
End Sub
End Class
H ....
e .
l .-..
o ---
?
w .--
o ---
r .-.
l .-..
d -..
! ?