?
Solved

Newbie Needs to read entire text file, display it to a textBox, be able to edit the text box and save any changes to same text file

Posted on 2005-03-23
6
Medium Priority
?
173 Views
Last Modified: 2010-04-23
I am very new at programming.
I am creating an app and need help on a couple of things.
I need to be able to read an entire already existing text file and display it in a textBox.
In this same textBox I need to be able to edit whats in the textBox and save it back to the original text file.
Any help would be appreciative.
0
Comment
Question by:jettman26
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 14

Expert Comment

by:amyhxu
ID: 13618724
This link has all the examples of creating(in your case, you don't need to create), reading, writing a text file:
http://www.builderau.com.au/program/windows/0,39024644,20267367,00.htm
0
 
LVL 14

Expert Comment

by:amyhxu
ID: 13618753
0
 
LVL 1

Assisted Solution

by:Anil_Poonia
Anil_Poonia earned 500 total points
ID: 13619155
Hi jettman26

Try this one

Private Sub SaveToFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToFile.Click
        Dim Write As String
        Dim sw As New StreamWriter("c:\my.txt", False)
        Write = Trim(RichTextBox1.Text)
        sw.WriteLine(Write)
        sw.Close()
        RichTextBox1.Text = ""
    End Sub

    Private Sub ReadFrmFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReadFrmFile.Click
        Dim read As String
        Dim sr As New StreamReader("c:\my.txt")
        RichTextBox1.Text = sr.ReadToEnd

        sr.Close()
    End Sub


With Refards

Anil
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:Anil_Poonia
ID: 13619167
Before use this code pls use following line

Imports System.IO

0
 
LVL 19

Accepted Solution

by:
Fahad Mukhtar earned 500 total points
ID: 13620184
use a RichtextBox Control, then you can use the builtin LoadFile() and SaveFile Methods for your problem:

'1 line code to Load a text file in Rich TextBox
RichTextBox1.LoadFile("C:\New Text Document.txt", RichTextBoxStreamType.PlainText)

'1 line code to save the same text file from Rich TextBox
RichTextBox1.SaveFile("C:\New Text Document.txt", RichTextBoxStreamType.PlainText)
0
 
LVL 27

Expert Comment

by:planocz
ID: 13621192
Hi,

Here is where I found good examples for getting started in VB.Net

.....http://msdn.microsoft.com/vbasic/downloads/samples/101samples.aspx

Link for ASP programs...

http://msdn.microsoft.com/asp.net/downloads/kits/default.aspx 
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question