\n is not working in concatenation code

  • Thread starter Thread starter J.S.
  • Start date Start date
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.

--
 
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.
 
Hi Mark,

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

Thanks,
J.S.
 
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.
 
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?
 
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.
 
Back
Top