Qbasicnews.com

Full Version: add new line to string
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
sorry i know this is an easy question so once its answered i will delete it. what are the things you add to the string to make in add a new line.. i forgot.

test$=test$+chr$(?)+chr$(?)

i think its something like that but i cant remember. thanks
chr$(13) is the equivalent of the enter key.
well i cant delete thanks for the reply man.
Another way you can do it is to use "option escape" which lets you insert some special metacharacters into strings:

Code:
Option Escape
Dim x As String
x = "First Line\nSecond Line"
Print x
Sleep
i tried chr$(13) for this

Code:
test$="hello"+chr$(13)+"test"
print test$

and it showed this

Quote:testo

to jofers:
i will check that out.
Works fine for me. :???:
Chr(13) is a "carriage" return. It's supposed to be like in old typewriters. To start a new line, you have a carriage return (moving the type head all the way to the left), and then a line feed (feeding the paper a bit through the typewriter)

So Chr(13) will return the cursor to the far left, and Chr(10) will start a new line. Change your code to this:

Code:
Print "Hello" + Chr(13, 10) + "Test"
Sleep

And you will be fine.
thank you for clearing that up for me jofers.