battle programmers alliance

battle programminga forum for elite programmerswith extreme will powerto sharpen theire skills
 
HomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in
Search
 
 

Display results as :
 
Rechercher Advanced Search
Latest topics
» text art canvas
Today at 8:55 pm by Moti Barski

» android mobile app dev APK
Today at 7:00 pm by Moti Barski

» links/suggestions to become a programmer
Mon May 07, 2018 11:01 pm by Moti Barski

» java eclipse oxygen grimoire
Thu May 03, 2018 8:24 pm by Moti Barski

» forum logo by tf monkey
Wed May 02, 2018 10:17 pm by Moti Barski

» java and MySQL
Mon Apr 30, 2018 3:02 pm by Admin

» mini A.I puzzles
Mon Apr 23, 2018 11:38 am by Moti Barski

» java convert string to unicode
Sun Mar 25, 2018 8:40 pm by Admin

» problem java dynamic web
Sat Mar 24, 2018 6:10 am by Admin

June 2018
SunMonTueWedThuFriSat
     12
3456789
10111213141516
17181920212223
24252627282930
CalendarCalendar
Social bookmarking
Social bookmarking digg  Social bookmarking delicious  Social bookmarking reddit  Social bookmarking stumbleupon  Social bookmarking slashdot  Social bookmarking yahoo  Social bookmarking google  Social bookmarking blogmarks  Social bookmarking live      

Bookmark and share the address of battle programmers alliance on your social bookmarking website
Share | 
 

 vb.net morse class coder + decoder

Go down 
AuthorMessage
Admin
Admin
avatar

Posts : 108
Join date : 2011-08-01

PostSubject: vb.net morse class coder + decoder   Sat Feb 17, 2018 11:20 am

hisatsu !!! double compile !!!!!!!!!!!!
Code:
Public Class morse
    Public Shared Function Code(ByVal user As String) As String
        Dim result As String = ""
        For index = 0 To user.Length - 1
            result &= charToMorse(user(index))
        Next
        Return result
    End Function
    Private Shared Function charToMorse(ByVal x As Char) As String
        Dim result As String = ""
        Select Case x
            Case "a"
                result = "*-"
            Case "b"
                result = "-***"
            Case "c"
                result = "-*-*"
            Case "d"
                result = "-**"
            Case "e"
                result = "*"
            Case "f"
                result = "**-*"
            Case "g"
                result = "--*"
            Case "h"
                result = "****"
            Case "i"
                result = "**"
            Case "j"
                result = "*---"
            Case "k"
                result = "-*-"
            Case "l"
                result = "*-**"
            Case "m"
                result = "--"
            Case "n"
                result = "-*"
            Case "o"
                result = "---"
            Case "p"
                result = "*--*"
            Case "q"
                result = "--*-"
            Case "r"
                result = "*-*"
            Case "s"
                result = "***"
            Case "t"
                result = "-"
            Case "u"
                result = "**-"
            Case "v"
                result = "***-"
            Case "w"
                result = "*--"
            Case "x"
                result = "-**-"
            Case "y"
                result = "-*--"
            Case "z"
                result = "--**"
            Case "0"
                result = "-----"
            Case "1"
                result = "*----"
            Case "2"
                result = "**---"
            Case "3"
                result = "***--"
            Case "4"
                result = "****-"
            Case "5"
                result = "*****"
            Case "6"
                result = "-****"
            Case "7"
                result = "--***"
            Case "8"
                result = "---**"
            Case "9"
                result = "----*"
            Case "."
                result = "*-*-*-"
            Case ","
                result = "--**--"
            Case "?"
                result = "**--**"
            Case " "
                result = "/"
            Case Else

        End Select
        Return result & "/"

    End Function
    Public Shared Function decoder(ByVal msg As String) As String
        Dim result As String = ""
        Dim morseChr As String = ""
        For index = 0 To msg.Length - 1
            If msg(index) <> "/" Then
                morseChr &= msg(index)
            Else
                result &= morseCharToChar(morseChr)
                morseChr = ""
            End If
        Next
        result = result.Replace("  ", " ")
        'result = result.replaceAll("  ", " ")
        Return result
    End Function
    Private Shared Function morseCharToChar(ByVal x As String) As Char
        Dim result As Char = "@"
        Select Case x
            Case "*-"
                result = "a"
            Case "-***"
                result = "b"
            Case "-*-*"
                result = "c"
            Case "-**"
                result = "d"
            Case "*"
                result = "e"
            Case "**-*"
                result = "f"
            Case "--*"
                result = "g"
            Case "****"
                result = "h"
            Case "**"
                result = "i"
            Case "*---"
                result = "j"
            Case "-*-"
                result = "k"
            Case "*-**"
                result = "l"
            Case "--"
                result = "m"
            Case "-*"
                result = "n"
            Case "---"
                result = "o"
            Case "*--*"
                result = "p"
            Case "--*-"
                result = "q"
            Case "*-*"
                result = "r"
            Case "***"
                result = "s"
            Case "-"
                result = "t"
            Case "**-"
                result = "u"
            Case "***-"
                result = "v"
            Case "*--"
                result = "w"
            Case "-**-"
                result = "x"
            Case "-*--"
                result = "y"
            Case "--**"
                result = "z"
            Case "-----"
                result = "0"
            Case "*----"
                result = "1"
            Case "**---"
                result = "2"
            Case "***--"
                result = "3"
            Case "****-"
                result = "4"
            Case "*****"
                result = "5"
            Case "-****"
                result = "6"
            Case "--***"
                result = "7"
            Case "---**"
                result = "8"
            Case "----*"
                result = "9"
            Case "*-*-*-"
                result = "."
            Case "--**--"
                result = ","
            Case "**--**"
                result = "?"
            Case "/"
                result = " "
            Case Else

        End Select
        If result = "@" Then
            result = " "
        End If
        Return result
    End Function
End Class
Shocked

_________________
kurayami no kagi  _____    
Back to top Go down
View user profile https://yotamarker.justforum.net
 
vb.net morse class coder + decoder
Back to top 
Page 1 of 1
 Similar topics
-
» Class 4 Softswitch For Rent
» Cannot locate the class Select in web driver
» how to identify element using xpath having same class names?
» Getting the error msg 'Error: Could not find or load main class java-jar' while executing the selenium code in eclipse
» how can call this class "x-window-header x-window-header-noborder x-unselectable x-window-draggable" from webdriver

Permissions in this forum:You cannot reply to topics in this forum
battle programmers alliance :: battle programming alliance :: battle programming-
Jump to: