Public Class Form1
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim i As Integer
Dim Code As String
TextBox2.Text = ""
For i = 1 To Len(TextBox1.Text)
Code = ""
If Mid$(TextBox1.Text, i, 1) = "a" Then Code = ".-"
If Mid$(TextBox1.Text, i, 1) = "á" Then Code = ".-"
If Mid$(TextBox1.Text, i, 1) = "b" Then Code = "-..."
If Mid$(TextBox1.Text, i, 1) = "c" Then Code = "-.-."
If Mid$(TextBox1.Text, i, 1) = "č" Then Code = "-.-."
If Mid$(TextBox1.Text, i, 1) = "d" Then Code = "-.."
If Mid$(TextBox1.Text, i, 1) = "ď" Then Code = "-.."
If Mid$(TextBox1.Text, i, 1) = "é" Then Code = "."
If Mid$(TextBox1.Text, i, 1) = "e" Then Code = "."
If Mid$(TextBox1.Text, i, 1) = "ě" Then Code = "."
If Mid$(TextBox1.Text, i, 1) = "f" Then Code = "..-."
If Mid$(TextBox1.Text, i, 1) = "g" Then Code = "--."
If Mid$(TextBox1.Text, i, 1) = "h" Then Code = "...."
If Mid$(TextBox1.Text, i, 1) = "ch" Then Code = "----"
If Mid$(TextBox1.Text, i, 1) = "i" Then Code = ".."
If Mid$(TextBox1.Text, i, 1) = "í" Then Code = ".."
If Mid$(TextBox1.Text, i, 1) = "j" Then Code = ".---"
If Mid$(TextBox1.Text, i, 1) = "k" Then Code = "-.-"
If Mid$(TextBox1.Text, i, 1) = "l" Then Code = ".-.."
If Mid$(TextBox1.Text, i, 1) = "m" Then Code = "--"
If Mid$(TextBox1.Text, i, 1) = "n" Then Code = "-."
If Mid$(TextBox1.Text, i, 1) = "ň" Then Code = "-."
If Mid$(TextBox1.Text, i, 1) = "o" Then Code = "---"
If Mid$(TextBox1.Text, i, 1) = "ó" Then Code = "---"
If Mid$(TextBox1.Text, i, 1) = "p" Then Code = ".--."
If Mid$(TextBox1.Text, i, 1) = "q" Then Code = "--.-"
If Mid$(TextBox1.Text, i, 1) = "r" Then Code = ".-."
If Mid$(TextBox1.Text, i, 1) = "ř" Then Code = ".-."
If Mid$(TextBox1.Text, i, 1) = "s" Then Code = "..."
If Mid$(TextBox1.Text, i, 1) = "š" Then Code = "..."
If Mid$(TextBox1.Text, i, 1) = "t" Then Code = "-"
If Mid$(TextBox1.Text, i, 1) = "ť" Then Code = "-"
If Mid$(TextBox1.Text, i, 1) = "u" Then Code = "..-"
If Mid$(TextBox1.Text, i, 1) = "ú" Then Code = "..-"
If Mid$(TextBox1.Text, i, 1) = "ů" Then Code = "..-"
If Mid$(TextBox1.Text, i, 1) = "v" Then Code = "...-"
If Mid$(TextBox1.Text, i, 1) = "w" Then Code = ".--"
If Mid$(TextBox1.Text, i, 1) = "x" Then Code = "-..-"
If Mid$(TextBox1.Text, i, 1) = "y" Then Code = "-.--"
If Mid$(TextBox1.Text, i, 1) = "ý" Then Code = "-.--"
If Mid$(TextBox1.Text, i, 1) = "z" Then Code = "--.."
If Mid$(TextBox1.Text, i, 1) = "ž" Then Code = "--.." 'Konec (malá písmena)
If Mid$(TextBox1.Text, i, 1) = "A" Then Code = ".-"
If Mid$(TextBox1.Text, i, 1) = "Á" Then Code = ".-"
If Mid$(TextBox1.Text, i, 1) = "B" Then Code = "-..."
If Mid$(TextBox1.Text, i, 1) = "C" Then Code = "-.-."
If Mid$(TextBox1.Text, i, 1) = "Č" Then Code = "-.-."
If Mid$(TextBox1.Text, i, 1) = "D" Then Code = "-.."
If Mid$(TextBox1.Text, i, 1) = "Ď" Then Code = "-.."
If Mid$(TextBox1.Text, i, 1) = "E" Then Code = "."
If Mid$(TextBox1.Text, i, 1) = "É" Then Code = "."
If Mid$(TextBox1.Text, i, 1) = "Ě" Then Code = "."
If Mid$(TextBox1.Text, i, 1) = "F" Then Code = "..-."
If Mid$(TextBox1.Text, i, 1) = "G" Then Code = "--."
If Mid$(TextBox1.Text, i, 1) = "H" Then Code = "...."
If Mid$(TextBox1.Text, i, 1) = "CH" Then Code = "----"
If Mid$(TextBox1.Text, i, 1) = "I" Then Code = ".."
If Mid$(TextBox1.Text, i, 1) = "Í" Then Code = ".."
If Mid$(TextBox1.Text, i, 1) = "J" Then Code = ".---"
If Mid$(TextBox1.Text, i, 1) = "K" Then Code = "-.-"
If Mid$(TextBox1.Text, i, 1) = "L" Then Code = ".-.."
If Mid$(TextBox1.Text, i, 1) = "M" Then Code = "--"
If Mid$(TextBox1.Text, i, 1) = "N" Then Code = "-."
If Mid$(TextBox1.Text, i, 1) = "Ň" Then Code = "-."
If Mid$(TextBox1.Text, i, 1) = "O" Then Code = "---"
If Mid$(TextBox1.Text, i, 1) = "Ó" Then Code = "---"
If Mid$(TextBox1.Text, i, 1) = "P" Then Code = ".--."
If Mid$(TextBox1.Text, i, 1) = "Q" Then Code = "--.-"
If Mid$(TextBox1.Text, i, 1) = "R" Then Code = ".-."
If Mid$(TextBox1.Text, i, 1) = "Ř" Then Code = ".-."
If Mid$(TextBox1.Text, i, 1) = "S" Then Code = "..."
If Mid$(TextBox1.Text, i, 1) = "Š" Then Code = "..."
If Mid$(TextBox1.Text, i, 1) = "T" Then Code = "-"
If Mid$(TextBox1.Text, i, 1) = "Ť" Then Code = "-"
If Mid$(TextBox1.Text, i, 1) = "U" Then Code = "..-"
If Mid$(TextBox1.Text, i, 1) = "Ú" Then Code = "..-"
If Mid$(TextBox1.Text, i, 1) = "Ů" Then Code = "..-"
If Mid$(TextBox1.Text, i, 1) = "V" Then Code = "...-"
If Mid$(TextBox1.Text, i, 1) = "W" Then Code = ".--"
If Mid$(TextBox1.Text, i, 1) = "X" Then Code = "-..-"
If Mid$(TextBox1.Text, i, 1) = "Y" Then Code = "-.--"
If Mid$(TextBox1.Text, i, 1) = "Ý" Then Code = "-.--"
If Mid$(TextBox1.Text, i, 1) = "Z" Then Code = "--.."
If Mid$(TextBox1.Text, i, 1) = "Ž" Then Code = "--.." 'konec (velká písmena)
If Mid$(TextBox1.Text, i, 1) = " " Then Code = "|" 'mezera mezi slovy
'...
If Code <> "" Then
TextBox2.Text = TextBox2.Text & Code
If i < Len(TextBox1.Text) And Code <> "|" Then
TextBox2.Text = TextBox2.Text & "|"
End If
End If
Next i
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer 'Čítač cyklů
Dim Src As String 'Zdroj
Dim Trgt As String 'Cíl
Dim Splt() As String 'Pole morseových písmen
Dim Code As String 'ANSI znak
Src = Replace(TextBox2.Text, "||", "| |") 'Mezera mezi slovy
Splt = Split(Src, "|") 'Rozdělit text do řádkú
Trgt = ""
For i = LBound(Splt) To UBound(Splt) 'Prohledat celé vzniklé pole
Code = ""
If Splt(i) = " " Then Code = " " 'Slovník znaků
If Splt(i) = ".-" Then Code = "a"
If Splt(i) = "-..." Then Code = "b"
If Splt(i) = "-.-." Then Code = "c"
If Splt(i) = "-.." Then Code = "d"
If Splt(i) = "." Then Code = "e"
If Splt(i) = "..-." Then Code = "f"
If Splt(i) = "--." Then Code = "g"
If Splt(i) = "...." Then Code = "h"
If Splt(i) = "----" Then Code = "ch"
If Splt(i) = ".." Then Code = "i"
If Splt(i) = ".---" Then Code = "j"
If Splt(i) = "-.-" Then Code = "k"
If Splt(i) = ".-.." Then Code = "l"
If Splt(i) = "--" Then Code = "m"
If Splt(i) = "-." Then Code = "n"
If Splt(i) = "---" Then Code = "o"
If Splt(i) = ".--." Then Code = "p"
If Splt(i) = "--.-" Then Code = "q"
If Splt(i) = ".-." Then Code = "r"
If Splt(i) = "..." Then Code = "s"
If Splt(i) = "-" Then Code = "t"
If Splt(i) = "..-" Then Code = "u"
If Splt(i) = "...-" Then Code = "v"
If Splt(i) = ".--" Then Code = "w"
If Splt(i) = "-..-" Then Code = "x"
If Splt(i) = "-.--" Then Code = "y"
If Splt(i) = "--.." Then Code = "z"
If Code <> "" Then
Trgt = Trgt & Code 'převod
End If
Next i
TextBox3.Text = Trgt 'Výstupní pole
End Sub