How to convert TODO Ascii written to text

0

Code:

PrivateSubBtnConvert_Click(senderAsObject,eAsEventArgs)HandlesBtnConvert.ClickConvertedTXT.Clear()IfTxtAscii.Checked=TrueThenWhileTheLength<>WaitingTXT.Text.LengthConvertedTXT.Text+=(AscW(WaitingTXT.Text(TheLength))&" ")
                TheLength += 1
            End While
            TheLength = 0
        ElseIf AsciiTxt.Checked = True Then
            ConvertedTXT.Text += (ChrW(WaitingTXT.Text(TheLength)) & " ")
        End If
    End Sub

Well, convert all text that the user wrote in txtbox to ASCII I got, but otherwise not, can anyone help me?

Note: I declared the variable "TheLength" as Double = 0.

    
asked by anonymous 09.02.2018 / 16:47

1 answer

0

The example available in Microsoft Developer Network I think it solves your problem:

Dim unicodeString As String = "This string contains the unicode character Pi (" & ChrW(&H3A0) & ")"

' Create two different encodings.
Dim ascii As Encoding = Encoding.ASCII
Dim unicode As Encoding = Encoding.Unicode

' Convert the string into a byte array.
Dim unicodeBytes As Byte() = unicode.GetBytes(unicodeString)

' Perform the conversion from one encoding to the other.
Dim asciiBytes As Byte() = Encoding.Convert(unicode, ascii, unicodeBytes)

' Convert the new byte array into a char array and then into a string.
Dim asciiChars(ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length) - 1) As Char

ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0)

Dim asciiString As New String(asciiChars)

MsgBox(asciiString)
    
01.08.2018 / 13:36