Last post Mar 12, 2008 06:10 PM by TonyDong
Mar 12, 2008 04:55 AM|isjf|LINK
I saw these code from a C# project , just wondering why there using Microsoft.visualBasic.ControlChars.CrLF
is it a VB controls or..something else? ( I'm not sure how to call it)
and what is 【Microsoft.visualBasic.ControlChars.CrLF】function?
textBox1.Text += strMsg + Microsoft.VisualBasic.ControlChars.CrLf;
textBox1.SelectionStart = textBox1.Text.Length - 1;
Mar 12, 2008 05:08 AM|TonyDong|LINK
In C#, we use \r\n for new line return, if you want to use new line in html, you can use server.htmldeode(strMsg+"<br />");
Mar 12, 2008 05:10 AM|Careed|LINK
To accommodate some of the VB functionality prior to .NET, the designers and developers of .NET has presented all users (not just VB users) with the ability to use this functionality. Thus, there exists a namespace called Microsoft.VisualBasic that contains
this functionality that includes special variables and methods that are similar to the same in pre-.NET VB.
Specifically, CrLf is "Carriage Return Line Feed". In other words, this starts a new line within a string.
Look at the MSDN documentation and look at the various Microsoft.VisualBasic namespaces that are there. This should give you more information about this field and other items of interest.
Mar 12, 2008 05:15 AM|sreejukg|LINK
\r - carreage return
\n new line
Mar 12, 2008 06:44 AM|isjf|LINK
so Microsoft.VisualBasic.ControlChars.CrLF = /r/n ?
does there have any difference between Microsoft.VisualBasic.ControlChars.CrLF and /r/n ?
or thery are just syntax different?
Mar 12, 2008 06:51 AM|mn.shelly|LINK
Check this one 'System.Environment.NewLine'
Mar 12, 2008 07:08 AM|isjf|LINK
thank you but... why metion 【System.Environment.NewLine】?
is the same function like /r/n?
what's the difference of them?
also ... any limit to use these functions?
can I use System.Environment.NewLine in WinForm?
Mar 12, 2008 11:31 AM|sreejukg|LINK
I dont think so there is any difference between these 2. if you are using both methods, the out put will be the same, it will add a carreage return and a line feed to the specified position
Mar 12, 2008 12:32 PM|Careed|LINK
All of these are just different ways to perform the process to create a new line within a string. They perform the same function.
The purpose of the different methods is how you approach the "problem" of creating a new line in a text string. If I'm a long-time VB developer, then I would be more inclined to use vbCrLf (which is a string field in the Microsoft.VisualBasic.Constants class)
; if I'm a C/C++/C# programmer, then "\r\n" would be more familiar to me; if I'm focusing on using more .NET in my code so I'm not too language-specific, I would more than likely use System.Environment.NewLine. So, it's really all of matter of perspective
and perception from the programmer's point of view.
Then again, why would some use Microsoft.VisualBasic.ControlChars.CrLf in a C# program? Maybe they're confused about all that .NET provides....[:D]
Mar 12, 2008 06:10 PM|TonyDong|LINK