Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[VB.NET] Add text file text to richtextbox.

This will allow you to browse and select a text file on your computer
and have the text put right into a textbox or richtextbox
on your program.

Just open a richtextbox, A command button, And 1 Openfiledialog.

[IMG]http://i30.[censored].com/2md1bvt.jpg[/IMG]

Put this code in after double clicking on the command button.

Code
OpenFileDialog1.ShowDialog()
        Dim fname As String = OpenFileDialog1.FileName
        If System.IO.File.Exists(fname) Then
            Dim read As New System.IO.StreamReader(fname)
            RichTextBox1.Text = read.ReadToEnd
            read.Close()
        Else
            MsgBox("Error: File does not exists, Please choose another")
        End If
    End Sub

[IMG]http://i25.[censored].com/aywtwz.jpg[/IMG]

You can now test out your program.
You will see that when you click on your command put
where you put the code in, you can browse and select a text file
off your computer to be added into the programs Richtextbox1.

[IMG]http://i30.[censored].com/34pjptw.jpg[/IMG]

Once you select which text file you would like
Double click on the text file or highlight the text
file you would like and click "Open" on the browser.
You will then see your text go into the richtextbox on the program
and you will be able to scroll through all of it and read it.
This is good for having "How to use" text files that come with your program, Since no one ever really opens the read me.txt or the how to use.txt
now you can add the choice right into the program incase
they eventually need to read it.

[IMG]http://i28.[censored].com/117wjft.jpg[/IMG]
This will be useful to me thanks.
Thats spiffy. Could be useful for numerous things.
You are very much welcome.
And yes, I used this method in several projects, Happens to be a great code.
Enjoy it.
(Aug 7, 2009 09:03 PM)Xx1232shooterxX Wrote:  This will be useful to me thanks.
I love your tutorials, not too advenced, but realy greats !

I already know this, but don't mind to see again !
I don't like to make my tutorials advanced, I like to show the noobs how to step there game up.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by PerileosMay 11, 2020 09:21 PM 24 614 May 11, 2020 09:21 PM
Last Post: Alien
[C] by pebblakOct 15, 2019 05:24 AM 6 304 Oct 15, 2019 05:24 AM
Last Post: Joseph Ducreux
[C#] by Iera NamhorunJun 26, 2019 04:28 AM 4 236 Jun 26, 2019 04:28 AM
Last Post: Iera Namhorun