|
-
Feb 2nd, 2000, 05:00 PM
#1
Thread Starter
Addicted Member
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!
-
Feb 2nd, 2000, 05:14 PM
#2
Frenzied Member
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]
-
Feb 2nd, 2000, 07:49 PM
#3
Addicted Member
Open filename for Input as #1
Text1.text = Input(Len(1),1)
Close #1
This uses the standard text box
------------------
Razzle
ICQ#: 31429438
-
Feb 2nd, 2000, 08:29 PM
#4
Fanatic Member
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
-
Feb 5th, 2000, 05:24 AM
#5
Thread Starter
Addicted Member
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!
-
Feb 6th, 2000, 10:59 AM
#6
Frenzied Member
Can you save using code this short for a RichTextBox also???
Steve
-
Feb 6th, 2000, 06:21 PM
#7
-
Feb 6th, 2000, 06:39 PM
#8
-
Feb 6th, 2000, 06:40 PM
#9
Frenzied Member
Or, just use
RichTextBox1.SaveFile [filename]
------------------
Mark "Buzby" Beeton
VB Developer
[email protected]
-
Feb 7th, 2000, 03:04 AM
#10
Thread Starter
Addicted Member
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|