-
[2.0] Newline?
I have a multiline textbox, which the user would type something into and press a button. The button does something with the text, depending on which characters are used. But i can't work out how to recognise a newline in the textbox. I thought i could do this:
Code:
if (tbxIn.Text[i] == Convert.ToChar(Environment.NewLine))
{
// action here...
}
-
Re: [2.0] Newline?
-
Re: [2.0] Newline?
Insted of getting this:
1st Line
2nd Line
I get this:
1st Line□2nd Line
-
1 Attachment(s)
Re: [2.0] Newline?
It would probably help if you could see what i needed it for:
The parts i need help with is in _Encrypt and _Decrypt procedures.
Ive attatched the project (without an EXE).
-
Re: [2.0] Newline?
Code:
if (tbxIn.Text[i] == '\n')
{
// action here...
}
-
Re: [2.0] Newline?
I tried that. I got this effect:
-
Re: [2.0] Newline?
I fixed it. Used RTB's insted of standard textboxs (which i was trying to avoid, but it doesnt really matter :D). Thanks for all the help.
-
Re: [2.0] Newline?
I guess I'm late for that but try the string "\r\n" instead of '\n' only
-
Re: [2.0] Newline?
As a little more explanation, Environment.NewLine is two character string containing a carriage return character ('\r') and a line feed character ('\n'). If you convert that to a char then you simply drop the line feed and get the carriage return. You haven't really specified what you're trying to do but you may be interested to know that both the TextBox and RichTextBox have a Lines property, which returns a string array of the Text split on the line breaks.