Results 1 to 9 of 9

Thread: add string to next line

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    10

    add string to next line

    how can i make a string i added to a label to go 2 the next line instead of adding it like it keeps moving to the right

  2. #2
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: add string to next line

    You can use vbCrLf (Carriage Return/Line Feed), ie:

    vb Code:
    1. Label1.Caption = "Line 1" & vbCrLf & "Line 2" & vbCrLf & "Line 3"

  3. #3
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: add string to next line

    It also works the same with textboxes, but you *need* to turn multiline on with a textbox otherwise the vbCrLf is just an ugly black box :-)
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    10

    Re: add string to next line

    that might work but theres gonna be a lot of lines and it has a input so on every input it needs to go to a new line

  5. #5
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: add string to next line

    If there's going to be a lot of lines, use a textbox with a scrollbar (you need to turn those on in properties too :-))

    If you're going to have a SERIOUS amount of lines, you'll need to use a *rich* textbox (RTB or RichTextBox) which can handle more than 64k of data (unlike a normal textbox, which is limited)
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  6. #6

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    10

    Re: add string to next line

    the "Line 1" didnt work either
    im using Microsoft Visual Basic 2005 Express
    instead of .caption it has .text

  7. #7
    Addicted Member
    Join Date
    May 2006
    Posts
    216

    Re: add string to next line

    Quote Originally Posted by CemeteryRidge
    the "Line 1" didnt work either
    im using Microsoft Visual Basic 2005 Express
    instead of .caption it has .text
    ure in wrong section..

  8. #8
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: add string to next line

    and if it has .text it isn't a label, it's a textbox.

    But yeah, as omfgz says, you need to post in the VB.NET section, we only deal with classic VB, which is VB6 and below for the most part
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  9. #9
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: add string to next line

    Fixing the height of the label is as simple as:

    vb Code:
    1. Private Sub Command1_Click()
    2.     Label1.Caption = Label1.Caption & vbCrLf & "Test"
    3.     Label1.Height = TextHeight(Label1.Caption) + 40
    4. End Sub

    VB.NET has an 'upgrade' feature to take a VB6 project and convert it to .NET. While there's usually errors, for something as simple as this I'm sure it will convert it correctly.

    I attached the VB6 project. Unzip it and open the .vbp file with VB.NET.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width