Text Box Text Displays Question 
Author Message
 Text Box Text Displays Question

I have a nubee VB 3.0 question...

I've created a text box on a form and want to drop about 150 lines of text
into the box for the user to read.  I have triggered the mutliline switch in
the properties box to add in the scroll bar.

Could some please tell me the best way to add this amount of text to a
text box?  Should I use the "print" command" or whatis the best and
easiest method.  BTW, the text consists of several paragraphs with
a carriage return between them.  ANy help or suggestions would be
appreciated.  Thanks.



Sat, 13 Jun 1998 03:00:00 GMT  
 Text Box Text Displays Question

Quote:

> Could some please tell me the best way to add this amount of text to a
> text box?  Should I use the "print" command" or whatis the best and
> easiest method.  BTW, the text consists of several paragraphs with
> a carriage return between them.  ANy help or suggestions would be
> appreciated.  Thanks.

The easiest way is probably to save the text in a file called
c:\mydir\mytext.txt, then do:

dim s as string
open "c:\mydir\mytext.txt" for binary as #1
s = space(lof(1))
get #1,,s
close #1
Text1.text = s

Hope this helps

 _  _____  _   _

| || (_) || `\| |
| ||  _  || , ` | If they give you lined paper, write the other way!
| || | | || |`\ |
(_)(_) (_)(_) (_) http://www.netlink.co.uk/users/igloo



Sat, 13 Jun 1998 03:00:00 GMT  
 Text Box Text Displays Question

(kmp) threw this at us:

Quote:
>Could some please tell me the best way to add this amount of text to a
>text box?  Should I use the "print" command" or whatis the best and
>easiest method.  BTW, the text consists of several paragraphs with
>a carriage return between them.  ANy help or suggestions would be
>appreciated.

You do not Print to a text box. You add text to it by referring
to the .Text property, like this:

TextBox.Text = "Hello World"

That places the text "Hello World" in the text box named TextBox.

Jens
--
* Everything I said are the opinions of someone else.   *
* I just cut-and-pasted.                                *

Jens Balchen jr.       http://www.sn.no/~balchen



Sun, 14 Jun 1998 03:00:00 GMT  
 Text Box Text Displays Question

Quote:

> I have a nubee VB 3.0 question...

> I've created a text box on a form and want to drop about 150 lines of text
> into the box for the user to read.  I have triggered the mutliline switch in
> the properties box to add in the scroll bar.

> Could some please tell me the best way to add this amount of text to a
> text box?  Should I use the "print" command" or whatis the best and
> easiest method.  BTW, the text consists of several paragraphs with
> a carriage return between them.  ANy help or suggestions would be
> appreciated.  Thanks.

Hi,
        What's wrong with txtMyTextBox.Text = sYourTextStr ??  Make a
text string of all of your lines with each line seperated by CrLF i.e.
chr(13)+chr(10), even empty lines.  Remember, despite what it might say
in the Help, you're limited to 32Kbytes for the text box, but 64Kbytes for
the string variable.

Hope this helps,
Steve



Sun, 14 Jun 1998 03:00:00 GMT  
 Text Box Text Displays Question


Quote:

>> Could some please tell me the best way to add this amount of text to a
>> text box?  Should I use the "print" command" or whatis the best and
>> easiest method.  BTW, the text consists of several paragraphs with
>> a carriage return between them.  ANy help or suggestions would be
>> appreciated.  Thanks.

>The easiest way is probably to save the text in a file called
>c:\mydir\mytext.txt, then do:

>dim s as string
>open "c:\mydir\mytext.txt" for binary as #1
>s = space(lof(1))
>get #1,,s
>close #1
>Text1.text = s

Similarly, you could:
''''''''''''''''''''''''''''''''''
Open "somefile.txt" for input as 1
Text1.text = input$(lof(1),1)
Close 1
''''''''''''''''''''''''''''''''''

I guess if you're getting paid per line of code, you'd want to
use the former method.

Both methods will bomb out if the file is more than about 32K,
so you could add a
''''''''''''''''''''
If lof(1) < 32000 then
        Text1.text = input$(lof(1),1)
Else
        Text1.text = "File too big! Bumer! Find another way to code me!"
Endif
'''''''''''''''''''



Sun, 14 Jun 1998 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Text Box Entry To Text Box Display?

2. Newbie Question - Moving from text box to text box (without tab)

3. Newbie question: Rich Text Box vs. Text Box

4. dear text box guru(s): fancy text box question...

5. reading a text file to display in text box

6. Rich Text box displaying last inserted text?

7. grabbing text and displaying it in a text box

8. Displaying text in a multiline text box

9. Display Text from variable in text box

10. Displaying formatted text in a text box or grid

11. I need to display the text of an html file in a text box

12. Display Only Text Box - Text Color/Background Color

 

 
Powered by phpBB® Forum Software