How to Display Multiple lines in a Label or Text Box
This is my first time submitting a question. Im quite new to Visual Basic programming. Im using VB 6.0 Leaning Edition. Im trying to write a number-adding program to use in a very specific area of my work. I have been successful in writing the program; i.e. it does what I want it to do. However, the question I have is this: Is it possible to display MULTIPLE lines of data, generated by my program, in a Label Box or Text Box? I know that a Text Box can ACCEPT multiple lines of inputted data if the Text Box property is set to multi line, but can it also display multiple lines of data generated by my program? If its possible to do this in either a Label Box or Text Box Id really appreciate an example of the code required? Below is the code that I have written to generate the kind of data I show at the bottom of this question:
Private Sub Form_Load()
Do
Add = InputBox("TYPE A NUMBER; TO END TYPE: '0'")
If Add = 0 Then GoTo 4
total = total + Val(Add)
count = count + 1
Print "Number "; coun, Add, "Total "; total
4 Loop Until Add = 0
Print tab(50); Total ;total
Print tab(50); Average ;total / count
End Sub
I currently am having the data displayed on the Form (if the AutoRedraw property is set to True). Id like to be able to print the displayed data, but I dont want to have to print the form to do it. It would be easier to print it from a Label Box or Text Box. Below is an example of the data that is displayed on the Form:
Number 1 12 12
Number 2 45 57
Number 3 87 144
Number 4 678 822
Etc
Etc
Total 822
Average 205.5
If anyone can help with this problem Id sure appreciate it. Thank you in advance to whom ever of you out there can help.
Sincerely,
Urbaud
[1834 byte] By [
Urbaud] at [2007-11-11 7:20:29]

# 1 Re: How to Display Multiple lines in a Label or Text Box
set the MultiLine property of the textbox to true (and you can also make the scollbars visible)
To append a line at the end use:
txt.SelStart = len(txt) '' set the starting insertion point at the end of the text
txt.Seltext = myLine + vbcrlf '' add a string plus the carriage return
For a Label, just format the string using vbcrlf as a line separator (but you have to resize the label to fit the text)
Marco
mstraf at 2007-11-11 17:27:06 >

# 4 Re: How to Display Multiple lines in a Label or Text Box
Hi Marco,
Thank you for your reply to my problem. I think I understood it and will try it. Is it ok for me to contact you again if I need help?
Dan
You are welcome. Please post any technical questions in the forum, where everyone can benefit from it. And you get a more broad audience and more probability to get an answer :-).
Marco
mstraf at 2007-11-11 17:30:12 >
