Welcome!
Thank you visiting ICB - Iceberg Code Blog
This is the place, where I'd like to share ideas and some useful code (VB, Excel, T-SQL, JavaScript, ...)
Table of Content
This is the place, where I'd like to share ideas and some useful code (VB, Excel, T-SQL, JavaScript, ...)
Table of Content
Friday, March 31, 2006
String 2 Morse
This is a function to translate any String in Morse Code,
I don't know if it is a useful function, but if you are
starting to study VBA, it's a nice code to read
I don't know if it is a useful function, but if you are
starting to study VBA, it's a nice code to read
Function txt2morse(ByVal text As String) As String Dim Letters As String, Morse As String, arrMorse() As String, i As Long Letters = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,?/:" Morse = " ,.-,-...,-.-.,-..,.,..-.,--.,....,..,.---,-.-,.-..,--,-.,---,.--.,--.-,.-.,...,-,..-,...-,.--,-..-,-.--,--..,-----,.----,..---,...--,....-,.....,-....,--...,---..,----.,.-.-.-,--..--,..--..,-..-. ,-...-" arrMorse = Split(Morse, ",") text = UCase(text) For i = 1 To Len(text) txt2morse = txt2morse & " " & arrMorse(InStr(1, Letters, Mid(text, i, 1)) - 1) Next txt2morse = Trim(txt2morse) End Function |