-
Could anyone please tell me what is the quickest way to open a text-file and get the contents into a textbox?
I have tried to open it sequential and read it line by line, or character by character, but it takes so much memory and time, I can only open small files (<10 kB)
Is there a way to open the whole file at once?
------------------
Wilhelm Tunemyr,
Sweden
[email protected]
"Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menchen"
Heinrich Heine (1797-1856)
Pravda zvítezi!
-
You could always use a Rich Text Box - you will need to add the MS RichTextBoxControl to your project via the components window.
With the Rich Text Box you can do this;
RichTextBox1.LoadFile "[filename]",1
to load a plain text file into it.
I don't know what the limitations are 'cos I never really use the RichText box.
------------------
Mark "Buzby" Beeton
VB Developer
[email protected]
-
Open filename for Input as #1
Text1.text = Input(Len(1),1)
Close #1
This uses the standard text box
------------------
Razzle
ICQ#: 31429438
-
I'll admit I use the richtextbox method myself from time to time (as above) but you should try the filesystemobjects in VB6 using text streams and writeall or write line (for list boxes and arrays). documantation is a little scetchy so its best to open projects,references and tick a link to "Scripting" then open the functions in the object browser (F2). Adding a reference saves you having to use set object etc like
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("c:\testfile.txt", True)
a.WriteLine("This is a test.")
a.Close
-
I tried using RichTextBox, and it works great.
Thanks!
------------------
Wilhelm Tunemyr,
Sweden
[email protected]
"Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menchen"
Heinrich Heine (1797-1856)
Pravda zvítezi!
-
Can you save using code this short for a RichTextBox also???
Steve
-
no problem at all.
Open filename for Output as #1
Print #1, Text1.text
Close #1
------------------
Razzle
ICQ#: 31429438
What is the difference between a raven?
-The legs. The length is equal, especially the right one. :D
-
Pentax, du schriebst Menchen anstatt Menschen ;)
------------------
[email protected]
...
Every program can be reduced to one instruction which doesn't work.
-
Or, just use
RichTextBox1.SaveFile [filename]
------------------
Mark "Buzby" Beeton
VB Developer
[email protected]
-
Donnerwetter!
You mean I have spelled it wrong in all my mails for the last two years, my posts here on vb-world and other places?
Quite emberassing...
Anyway, thanks for telling me. I shall get it changed right away.
------------------
Wilhelm Tunemyr,
Sweden
[email protected]
"Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menschen"
Heinrich Heine (1797-1856)
Pravda zvítezi!