Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

VB line break in a string

Options
  • 01-03-2006 8:59pm
    #1
    Registered Users Posts: 1,987 ✭✭✭


    Anyone know how to put a simple line break in a string for example:

    I want strTitle to be on one line and strMetaKeywords to be underneath it when the appear in the textbox txtTitleBarCode!
    I've googled it and only gotten answer that invlove min of 40 lines of code!
    All help appreiated!
    txtTitleBarCode.Text = strTitle + strMetaKeywords


Comments

  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    txtTitleBarCode.Text = strTitle + "\r\n" + strMetaKeywords.

    Make sure its a multline textbox aswell.


  • Registered Users Posts: 1,987 ✭✭✭Ziycon


    txtTitleBarCode.Text = strTitle + "\r\n" + strMetaKeywords.

    Make sure its a multline textbox aswell.

    Tried that but it just prints out \r\n in the text box and it is set as multi line!


  • Moderators, Education Moderators, Motoring & Transport Moderators Posts: 7,395 Mod ✭✭✭✭**Timbuk2**


    I think this is what you want

    I think that Mutant_Fruit is thinking of Java!!! :)

    The syntax is
    			 				txtTitleBarCode.Text = txtTitle & vbNewLine & txtMetaKeyWords
    

    You could also replace vbNewLine with vbCrLf, but it would do the exact same thing

    Note that in Visual Basic for joining strings you should use & instead of +. Even though it will work with +, and many people use the + out of habit because that is the proper syntax in Java, C# and C++, but in Visual Basic it is the &


  • Registered Users Posts: 1,987 ✭✭✭Ziycon


    Nice one lads, its a year since i used vb and its hard(coding habits) when you get used to coding in c or java and then u have to go back to vb coding!


  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    whoops, didn't even notice it was VB. Oh well :p


  • Advertisement
  • Registered Users Posts: 250 ✭✭ikoonman


    txtTitleBarCode.Text = strTitle & VbCrLf & strMetaKeywords
    

    Test it by echoing in a MsgBox first


Advertisement