\n is not working in concatenation code

J

J.S.

The new line (\n) code in the code below doesn't seem to work:

textBox1.Text = "<%\n" + comboBox1.SelectedItem +
"(\"" + textBox2.Text + "\")\n%>";

Instead of giving me:

<%
var1("var2")
%>

it is giving me:

<%var1("var2")%>

Is there an error in my code?

Thanks,
J.S.

--
 
G

Guest

Hi J.S,
instead of concatenating \n in your code try using
System.Environment.NewLine
i.e.

textBox1.Text = "hello" + System.Environment.NewLine + "how are you?"

this should work for you.

Hope that helps
Mark R Dawson.
 
J

J.S.

Hi Mark,

That worked perfectly! Do you know why \n doesn't work in this context?

Thanks,
J.S.
 
M

Morten Wennevik

Hi J.S.

On Windows systems a newline is \r\n. Some controls and objects are forgiving and will break the line with just \n, but not all of them.

Environment.NewLine uses \r\n on windows systems, \n on other systems etc.
 
U

Usenet User

Hi Mark,

That worked perfectly! Do you know why \n doesn't work in this context?

Thanks,
J.S.

"\n" = 0x0A (new line)
Environment.NewLine = "\r\n" = 0x0D0A (carriage return + new line)

Your code with "\n" worked as well, you just couldn't see it for some
reason. How did you try to evaluate your output?
 
J

J.S.

Usenet User said:
"\n" = 0x0A (new line)
Environment.NewLine = "\r\n" = 0x0D0A (carriage return + new line)

Your code with "\n" worked as well, you just couldn't see it for some
reason. How did you try to evaluate your output?

I was displaying the output in a textbox.

Thanks,
J.S.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top