473,657 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loading a file into a TextBox

Hi

How can I load a text file into a TextBox?

I have used System.Text.Str ingBuilder for fast loading. This method
works fine under windows XP, but it does not work in windows 98.

Any idea is appreciated.
thnx in advance.
Nov 20 '05 #1
9 2254
Cor
Hi MSDousti,

Can you suply some code, because this sounds strange,

I asume you read a file with a database or a streamreader in a stringbuilder
and than you say something as
\\\
me.textbox1.tex t = sb.tostring
///

Cor

How can I load a text file into a TextBox?

I have used System.Text.Str ingBuilder for fast loading. This method
works fine under windows XP, but it does not work in windows 98.

Nov 20 '05 #2
"MSDousti" <MS******@myrea lbox.com> schrieb

How can I load a text file into a TextBox?

I have used System.Text.Str ingBuilder for fast loading. This
method works fine under windows XP, but it does not work in windows
98.


"Does not work" means? Wrong result? Which result? Exception?
Relevant code? The Stringbuilder shouldn't be a problem.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
* MS******@myreal box.com (MSDousti) scripsit:
How can I load a text file into a TextBox?

I have used System.Text.Str ingBuilder for fast loading. This method
works fine under windows XP, but it does not work in windows 98.


Please be more specific. Error message? What's not working as expected?

"Post code!"

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Hi again,
Excuse me for my strange explanations about the situation.
Really, that was because of the "strange" situation that was happened!

I have played with my app an hour or two, and finally I found out the
reason.

As I have explained before, when I load a file into my TextBox (called
mainTB) in windows XP, there is no problem. But in windows 98, nothing
shows up. I think that's because of the file size. When file size is
less than 40KB or so, there's no problem in 98. But for larger files,
the problem arises. My app is not supposed to handle very large files.
I think the largest file it should handle is about 5MB. This strange
thing does not take place in XP.

(More details:)
When I paste a text more than 40KB into mainTB, nothing happenes. But
I can paste texts with size less than 40KB normally.

If u want to know more details, here u r (I have enhanced my code, so
that it doesn't use StringBuilder anymore):

If OpenFileDialog1 .ShowDialog(Me) = DialogResult.OK Then
Dim sr As StreamReader
sr = File.OpenText(O penFileDialog1. FileName)
mainTB.Text = sr.ReadToEnd
sr = Nothing
END If
Another notice:
In windows 98, notepad cannot open large files and asks us if we want
to open the file with wordpad. Is this problem related to mine?

If the problem is related to TextBox implementation in windows 98,
what can I do? (I also cannot use RichTextBox, 'cause it is too slow
for loading even little files)
Nov 20 '05 #5
Cor
Hi MSdousti,

I have not direct an answer but when I had this problem I would split up my
problem first
If OpenFileDialog1 .ShowDialog(Me) = DialogResult.OK Then
Dim sr As StreamReader
sr = File.OpenText(O penFileDialog1. FileName)
I would read it line by line to a stringbuilder and then put that
stringbuilder to the textbox
mainTB.Text = sr.ReadToEnd
sr = Nothing
It has nothing to do with it, but why not just sr.close?
END If


I hope this helps,

Cor
Nov 20 '05 #6
Cor
Sorry MsDousti,

I overlooked that you did use the stringbuilder, suddenly after posting I
remembered me that that was in your first post.

But why you not do that again and see step by step what gives the error, I
would even just put a string between it, while testing.

But now we know it is not the stringbuilder which what you started as
posible error causses it.

:-))

Cor
Nov 20 '05 #7
Hi Core.
I cannot load the file line by line into the textbox, because it takes
a lot of time. u can test this. Try a 1MB file, and open it in this
manner to see what happens.

sincerely urs,
MSD.
Nov 20 '05 #8
Cor
Hi MS,

I mean to point out where is the error?

And than bring it back in a more fast situation.

Cor
Nov 20 '05 #9
Hi
The problem is (as I said B4): when I open a file into a textbox using
the code I mentioned earlier, NOTHING SHOWS UP in the textbox. Please
try the code in windows 98 to open a 500KB (or larger) file. Does ur
textbox show the file?
Nov 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2304
by: José Joye | last post by:
Hello, I'm playing around with dynamically loading user controls ...and having problems I created a really simple userControl (in fact contains a plain text box) and placed it into the MyTestCtrl2.ascx file. In an aspx file I placed the following in the Page_Load method:
7
1562
by: Tim | last post by:
I am trying to load both server and user controls into placeholder controls on a aspx template page at runtime. These values would be strings that are returned from a database query. I know I can do this for user controls easily using: oContent = (ControlBase) Page.LoadControl(Session + ".ascx"); this.plcContent.Controls.Add(oContent); but can not figure out how to do it for server controls. since I do not know what the control...
1
1413
by: ACaunter | last post by:
Hi all, Could someone please explain to me how i could load a different datagrid or fill out all the textboxes with feilds from a database - once a user types a character in a textbox. I have the code for it, but my problem is that it doesn't work unless i click on an empty button, just to reload the page... also how would i control the direction of the tabbing on my ASP.Net webpage??? Thanks, adam
12
2198
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control server. It "serves" back the required control (either WebControl or UserControl) based on the contents of an xml file. The code in the webform places each control in a TableCell. My problem is that the control server works as far as returning the...
1
1120
by: Danny | last post by:
Hi, I've create a usercontrol with a Calendar Control and a Textbox. The SelectionChanged event of the calendar populates the textbox with the selected date. Also, I've created an aspx page with an ASP Table on the page.
9
25832
by: Jason Boardman | last post by:
Can anyone tell me how I can write HTML to a WebBrowser control in Visual Basic 6? I want to display HTML in the browser that is generated from within my VB program (as opposed to loading it from a file or URL). Is this possible? Jason
4
1508
by: mrmagoo | last post by:
I'm building a vb.net Forms project that is getting data from a SQL Server database. One of the main goals of the project is to be really responsive to events, such as textbox change events. I have a textbox for searching, a listbox to display the searched results, and a big textbox (memo) to display the clicked-results of the listbox item. My question is: should I load the controls with objects, and therefore store everything in...
1
1746
by: Nathan Sokalski | last post by:
I am revieving the following error for one of my controls when loading any pages that use it: Server Error in '/exposure/app' Application. -------------------------------------------------------------------------------- Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
0
2396
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile View I want the form populated from there profile on the sql server. The code to save the profile works fine. But when the user logs back in they data doesn't load back to the form. The multiview is located inside the LoginView's Logged-In View ....
0
8425
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8326
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8743
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8522
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5647
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1736
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.