|
-
Oct 15th, 2000, 03:36 AM
#1
Thread Starter
New Member
Hi all,
Sometime ago I asked here how to present a text file that I read on a form. I got an answer that suggested me simply to use a text box control.
Problem is that I read that file in a loop. something like:
While (NOT EOF)
read....
Textbox1.text = read_str
Wend
now each line erase the other and I can not display the whole file.
How to avoid it?
Should I use a different control? which one?
Thanks.
-
Oct 15th, 2000, 03:58 AM
#2
Lively Member
Try enabling multiline for the textbox.
btw, isn't there a limit for the number of characters u can place in a string?
-
Oct 15th, 2000, 04:05 AM
#3
transcendental analytic
A string character limit is s^31 that's 2 gigabyte so that's not the problem but a textbox character limit is 65536 byte + that nullchars will cut off the rest of the text.
Use & operater to add up strings instead of overwriting it again and again.
Don't read a file line by line, open in binary and get the whole file in one chunk:
Code:
Dim buffer as string
Open file for binary as #1
buffer=space(lof(1))
Get#1,,buffer
close #1
'now if that text file is smaller than 65536 bytes then you could put it in a textbox else put it in a richtextbox or leave it in the string.
TExt1=buffer
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 15th, 2000, 04:13 AM
#4
Thread Starter
New Member
I did try the multiline property, but it did not help.
And as for the limit, I limit the string that I read for 200 chars and it works OK.
-
Oct 15th, 2000, 06:55 AM
#5
New Member
You have to add the string to the textbox, like this:
Text1.text = Text1.text + read_str
if you want to do it line by line.
-
Oct 15th, 2000, 08:51 AM
#6
Frenzied Member
If you decide to use Line Input, use this
Code:
Text1.text = Text1.text & read_str
'Because if:
'text.text = 4
'readstr = 4
'it will result in
'Text1.Text = 44
instead of this
Code:
Text1.text = Text1.text + read_str
'Because if:
'text.text = 4
'readstr = 4
'it will result in
'Text1.Text = 8 < not what we want huh?
Get why?
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Oct 15th, 2000, 09:12 AM
#7
New Member
Sorry, I meant & and not +.
But + will work if it's only text...
[Edited by Tote on 10-15-2000 at 10:14 AM]
-
Oct 15th, 2000, 01:12 PM
#8
Use the following method instead of Line Input.
Code:
Open "MyTextFile.txt" For Input As #1
Text1 = Input(LOF(1), 1)
Close #1
-
Oct 15th, 2000, 01:26 PM
#9
transcendental analytic
Should have known this, if you post something then everyone comes with their own suggestion, well hope you don't choose one of the "adding upp strings"-solutions
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
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
|