bn2vs
Terugkerende gebruiker
- Lid geworden
- 18 aug 2007
- Berichten
- 1.705
Ik heb de volgende code:
Als ik text naar morse vertaal gaat het goed, zolang ik gewone tekens gebruik... als ik speciale tekens gebruik komt er om een of andere reden iets extra bij, dat als ik het terug naar gewone text vertaal .v is, meestal meeredre keren .v :shocked: Doe ik iets verkeerd?
Alvast bedankt
PHP:
Private Function codecConvertion(ByVal str As String, _
ByVal toCode As Boolean, ByVal codec(,) As String) As String
str = str.Trim.ToLower
Dim a, b As Int16
If toCode Then
a = 0 : b = 1
Else
a = 1 : b = 0
End If
For x As Int16 = LBound(codec, 1) To UBound(codec, 1)
str = str.Replace(codec(x, a), codec(x, b))
Next
Return str
End Function
Public Function morseConvertion(ByVal morseStr As String, ByVal toMorse As Boolean) As String
Dim morseCodec(,) As String = { _
{"?", "..-.../"}, _
{"_", "..-..-/"}, _
{".", ".-.-.-/"}, _
{"@", ".--.-./"}, _
{"'", ".----./"}, _
{"-", "-....-/"}, _
{";", "-.-.-./"}, _
{"!", "-.-.--/"}, _
{"(", "-.--../"}, _
{")", "-.--.-/"}, _
{",", "--..--/"}, _
{":", "---.../"}, _
{"0", "-----/"}, _
{"9", "----./"}, _
{"8", "---../"}, _
{"7", "--.../"}, _
{"6", "-..../"}, _
{"5", "...../"}, _
{"4", "....-/"}, _
{"3", "...--/"}, _
{"2", "..---/"}, _
{"1", ".----/"}, _
{"+", ".-.-./"}, _
{"=", "-...-/"}, _
{"/", "-..-./"}, _
{"ch", "----"}, _
{"h", "..../"}, _
{"v", "...-/"}, _
{"f", "..-./"}, _
{"u", "..--/"}, _
{"l", ".-../"}, _
{"a", ".-.-/"}, _
{"p", ".--./"}, _
{"j", ".---/"}, _
{"b", "-.../"}, _
{"x", "-..-/"}, _
{"c", "-.-./"}, _
{"y", "-.--/"}, _
{"z", "--../"}, _
{"q", "--.-/"}, _
{"o", "---./"}, _
{"s", ".../"}, _
{"u", "..-/"}, _
{"r", ".-./"}, _
{"w", ".--/"}, _
{"d", "-../"}, _
{"k", "-.-/"}, _
{"g", "--./"}, _
{"o", "---/"}, _
{"i", "../"}, _
{"a", ".-/"}, _
{"n", "-./"}, _
{"m", "--/"}, _
{"e", "./"}, _
{"t", "-/"}, _
{" ", "/"}}
Return codecConvertion(morseStr, toMorse, morseCodec)
End Function
Als ik text naar morse vertaal gaat het goed, zolang ik gewone tekens gebruik... als ik speciale tekens gebruik komt er om een of andere reden iets extra bij, dat als ik het terug naar gewone text vertaal .v is, meestal meeredre keren .v :shocked: Doe ik iets verkeerd?
Alvast bedankt
