Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

VB line break in a string

  • 01-03-2006 08:59PM
    #1
    Registered Users, Registered Users 2 Posts: 1,991 ✭✭✭


    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, Registered Users 2 Posts: 1,991 ✭✭✭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,396 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, Registered Users 2 Posts: 1,991 ✭✭✭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, Registered Users 2 Posts: 250 ✭✭ikoonman


    txtTitleBarCode.Text = strTitle & VbCrLf & strMetaKeywords
    

    Test it by echoing in a MsgBox first


Advertisement