-
How to Display Multiple lines in a Label or Text Box
This is my first time submitting a question. I’m quite new to Visual Basic programming. I’m using VB 6.0 Leaning Edition. I’m 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 it’s possible to do this in either a Label Box or Text Box I’d 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). I’d like to be able to print the displayed data, but I don’t 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 I’d sure appreciate it. Thank you in advance to whom ever of you out there can help.
Sincerely,
Urbaud
-
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
"There are two ways to write error-free programs. Only the third one works."
Unknown
-
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
-
There is a property called multiline=false | true. Try this one.
-
 Originally Posted by Urbaud
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
"There are two ways to write error-free programs. Only the third one works."
Unknown
Similar Threads
-
Replies: 1
Last Post: 11-08-2005, 08:42 AM
-
By Spumbu1977 in forum VB Classic
Replies: 1
Last Post: 10-15-2005, 12:17 PM
-
By Steve in forum ASP.NET
Replies: 0
Last Post: 07-29-2002, 06:25 PM
-
By Jason Hall in forum ASP.NET
Replies: 0
Last Post: 10-29-2001, 12:56 PM
-
By Mohamed Abu Zur in forum Java
Replies: 1
Last Post: 09-29-2000, 11:41 AM
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
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|