Load text file into RichTextBox
Load text file into RichTextBox
Load text file into RichTextBox
Load text file into RichTextBox
Load text file into RichTextBox
Load text file into RichTextBox Load text file into RichTextBox Load text file into RichTextBox Load text file into RichTextBox Load text file into RichTextBox Load text file into RichTextBox Load text file into RichTextBox Load text file into RichTextBox
Load text file into RichTextBox Load text file into RichTextBox
Load text file into RichTextBox
Go Back  Xtreme Visual Basic Talk > > > Load text file into RichTextBox


Reply
 
Thread Tools Display Modes
  #1  
Old 06-21-2004, 12:54 PM
fackrellb fackrellb is offline
Centurion
 
Join Date: Jun 2004
Location: Maryland USA
Posts: 105
Default Load text file into RichTextBox


Does anybody know how to open a text file and load it into RichTextBox without using the OpenFileDialog?

I want a specific text file (the path will be hard coded, for now) to open and be read into a RichTextBox when the form opens.

Thanks
Brad
Reply With Quote
  #2  
Old 06-21-2004, 01:06 PM
MKoslof's Avatar
MKoslofLoad text file into RichTextBox MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

How big is the text file? The string object in .Net should be able to hold the amount of the data that you need. If we are talking about a REALLY big file, we would have to tweak this, but this alone, should be fine:

Code:
Dim myOutput As StreamReader Dim sValues As String myOutput = New StreamReader("C:\test\Data.txt") sValues = myOutput.ReadToEnd Me.RichTextBox1.Text = sValues
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
  #3  
Old 06-21-2004, 01:25 PM
fackrellb fackrellb is offline
Centurion
 
Join Date: Jun 2004
Location: Maryland USA
Posts: 105
Default

Excellent!

That works great!!

Thanks
Brad
Reply With Quote
  #4  
Old 06-21-2004, 01:28 PM
MKoslof's Avatar
MKoslofLoad text file into RichTextBox MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

No problem, glad to help. Good luck!
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
  #5  
Old 06-21-2004, 03:09 PM
rot13 rot13 is offline
Regular
 
Join Date: Apr 2004
Location: Johnson City, Tennessee
Posts: 63
Default

umm... wouldnt it be easier to do rtb.loadfile(path as string) if your just doing something that simple?
__________________
Max Schmeling
Reports Developer
Reply With Quote
  #6  
Old 06-21-2004, 07:44 PM
MKoslof's Avatar
MKoslofLoad text file into RichTextBox MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

Yes, you could do it that way too. But what exactly is wrong with the StreamReader method? There is nothing wrong with it. There are several potential ways to do this..I presented the first one that came to mind. But thanks for your input.
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Load text file into RichTextBox
Load text file into RichTextBox
Load text file into RichTextBox Load text file into RichTextBox
Load text file into RichTextBox
Load text file into RichTextBox
Load text file into RichTextBox Load text file into RichTextBox Load text file into RichTextBox Load text file into RichTextBox Load text file into RichTextBox Load text file into RichTextBox Load text file into RichTextBox
Load text file into RichTextBox
Load text file into RichTextBox
 
Load text file into RichTextBox
Load text file into RichTextBox
 
-->