C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » VB.NET Syntax »

Text to Binary conversion


Posted Date: 06 Aug 2009    Resource Type: Code Snippets    Category: VB.NET Syntax
Author: A.SoumyaLaxmiMember Level: Bronze    
Rating: 1 out of 5Points: 7



Description :


This code shows how to perform Text to Binary conversion


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fstream As New FileStream("E:/textdata2.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite)
Dim sw As New StreamWriter(fstream)
sw.WriteLine(TextBox1.Text)
sw.Close()
MsgBox("Data converted in File")
fstream.Close()
Dim arr() As Char = TextBox1.Text.ToCharArray
Dim fsbw As New FileStream("E:/textdata3.txt", FileMode.OpenOrCreate, FileAccess.Write)
Dim bw As New BinaryWriter(fsbw)
bw.BaseStream.Seek(0, SeekOrigin.End)
For i As Integer = 1 To TextBox1.Text.Length - 1
bw.Write(CStr(arr(i)))
Next
bw.Close()
fsbw.Close()

Dim fs As New FileStream("E:/textdata3.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite)
Dim sr As New StreamReader(fs)
Dim str As String
str = sr.ReadLine()
While str <> ""
TextBox2.Text += str + vbCrLf
str = sr.ReadLine()
End While
sr.Close()
TextBox2.ReadOnly = True
fs.Close()

End Sub


Attachments

  • Text to binary conversion (31144-6221-TextToBinary.rar)


  • Responses

    Author: harjit    01 Oct 2009Member Level: Bronze   Points : 1
    Private Sub cmdConvtoBin_Click() MainText = Text1.Text ConvertBin MainText Text1.Text = MainTextEnd Sub


    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Sign In to add tags.
    [code]  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: Export datatable to excel
    Previous Resource: Shell & Shell wait Command in VB
    Return to Discussion Resource Index
    Post New Resource
    Category: VB.NET Syntax


    Post resources and earn money!
     
    More Resources



    dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use