How to Display Multiple lines in a Label or Text Box


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: How to Display Multiple lines in a Label or Text Box

  1. #1
    Join Date
    Nov 2005
    Location
    Edmonton, Alberta, Canada
    Posts
    30

    How to Display Multiple lines in a Label or Text Box

    This is my first time submitting a question. I知 quite new to Visual Basic programming. I知 using VB 6.0 Leaning Edition. I知 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痴 possible to do this in either a Label Box or Text Box I壇 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); 典otal ;total
    Print tab(50); 鄭verage ;total / count
    End Sub

    I currently am having the data displayed on the Form (if the AutoRedraw property is set to True). I壇 like to be able to print the displayed data, but I don稚 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壇 sure appreciate it. Thank you in advance to whom ever of you out there can help.

    Sincerely,

    Urbaud

  2. #2
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    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

  3. #3
    Join Date
    Nov 2005
    Location
    Edmonton, Alberta, Canada
    Posts
    30
    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

  4. #4
    Join Date
    Nov 2005
    Posts
    7
    There is a property called multiline=false | true. Try this one.

  5. #5
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    Quote 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

  1. Replies: 1
    Last Post: 11-08-2005, 08:42 AM
  2. Display Minutes in text box
    By Spumbu1977 in forum VB Classic
    Replies: 1
    Last Post: 10-15-2005, 12:17 PM
  3. Replies: 0
    Last Post: 07-29-2002, 06:25 PM
  4. Text Box not displaying full text value???
    By Jason Hall in forum ASP.NET
    Replies: 0
    Last Post: 10-29-2001, 12:56 PM
  5. The number of lines in an HTML text box.
    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center