Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If TextBox1.Text <> "" Then Dim Result As New System.Text.StringBuilder Dim val As String = Nothing 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 Else MsgBox("Please enter the text string you wish to convert to binary.", MsgBoxStyle.Critical, "ERROR") End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Try Dim Characters As String = System.Text.RegularExpressions.Regex.Replace(TextBox1.Text, "[^01]", "") Dim ByteArray((Characters.Length / 8) - 1) As Byte Dim val As String = Nothing 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 Catch MsgBox("Malformed Binary- Please Try Again.", MsgBoxStyle.Critical, "Error") TextBox2.Text = "" End Try End Sub End Class