Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

How would i get this:


Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

	Dim line As String = ""

	Dim SR As New IO.StreamReader(TextBox2.Text)

	Dim SB As System.Text.StringBuilder = New System.Text.StringBuilder
	Do
		line = SR.ReadLine
		If line <> TextBox4.Text Then
			SB.Append(line)
			SB.Append(System.Environment.NewLine)
		End If
	Loop Until line = ""
	SR.Close()

	Dim SW As New IO.StreamWriter(TextBox2.Text, False)

	SW.Write(SB.ToString())
	SW.Close()

End Sub

 

To read every line?

 

Also how would i read this from a file? (.txt file)

 

I want it to read the whole file and display it in a textbox... (like what notepad does)

Posted

this doesn't seem to be working:

       Dim oFile As System.IO.File
       Dim oRead As System.IO.StreamReader
       oRead = oFile.OpenText("D:\Image.txt")
       Dim EntireFile As String
       EntireFile = oRead.ReadToEnd()
       TextBox2.Text = EntireFile 

Posted

dim sr as streamreader = new streamreader("c:\test.txt")

do until sr.peek =< 0

debug.writeline sr.readline

loop

 

if you want to whole file at once you could try binary mode

BS - Beer Specialist
Posted

i've been wondering this for a while... what does debug.writeline do?

 

Is there anyway to change the debug.writeline to something that with textbox1.text...

Posted (edited)

Yay, i got it working, i just mixed the two together:

 

        Dim line As String = ""
       Dim sr As System.IO.StreamReader = New System.IO.StreamReader("C:/text.txt")
       Do             
           line = sr.ReadLine
           If line <> TextBox2.Text Then
               TextBox2.AppendText(line)
               TextBox2.AppendText(System.Environment.NewLine)
           End If
       Loop Until line = ""

 

Do you know how i could do this now by writing to a file?

Edited by decrypt
  • Leaders
Posted

How could you do what by writing to a file?

To write to a file, use StreamWriter instead of StreamReader. :)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Posted
How could you do what by writing to a file?

To write to a file, use StreamWriter instead of StreamReader. :)

 

i just want to know how you can write text to a text file, simply...

Posted
i just want to know how you can write text to a text file' date=' simply...[/quote']

 

Dim SW As New IO.StreamWriter("where to write") 
       SW.WriteLine("what to write")  'example: TextBox1.Text
       SW.Close()

It's not impossible, it's Inevitable.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...