Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[vb.net] text to binary
#1
Code:
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 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 End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim Val As String = Nothing Dim Characters As String = System.Text.RegularExpressions.Regex.Replace(TextBox1.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 End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click TextBox1.Clear() End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Form2.Show() End Sub End Class

Download Source Code
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [VB10] Membuat Aplikasi Text to Speech fxmcspb 4 165 02-14-2013, 10:42 PM
Last Post: IT.ARiF9211
  text to SPEECH Evil Gnome 11 228 11-28-2011, 12:59 PM
Last Post: bie_van
  [SC VB6] Alay Text Generator mydisha 15 338 06-13-2011, 03:26 PM
Last Post: devilzsystem

Forum Jump:


Users browsing this thread: 1 Guest(s)