how to convert text to binary vis versa using vb2008

Опубликовано: 06 Июнь 2026
на канале: TFPtutorials
889
2

codes in description:

i also just got a new mic, since my old one was crappy, it will b in my next vid

codes:

Text To Binary:
Dim Val As String = Nothing
Dim Result As New System.Text.StringBuilder
For Each Character As Byte In System.Text.ASCIIEncoding.ASCII.GetBytes(TextBox1.Text)
Result.Append(Convert.ToString(Character, 2).PadLeft(8, "0"))
Result.Append(" ")
Next
Val = Result.ToString.Substring(0, Result.ToString.Length - 1)
TextBox2.Text = Val

Binary To Text:
Dim Val As String = Nothing
Dim Characters As String = System.Text.RegularExpressions.Regex.Replace(TextBox2.Text, "[^01]", "")
Dim ByteArray((Characters.Length / 8) - 1) As Byte
For Index As Integer = 0 To ByteArray.Length - 1
ByteArray(Index) = Convert.ToByte(Characters.Substring(Index * 8, 8), 2)
Next
Val = System.Text.ASCIIEncoding.ASCII.GetString(ByteArray)
TextBox2.Text = Val