|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
How can you in vb.net write vbCrLf to a file without using the
visualbasic namespace? In C# you would just case 10/13 to char and right that. I can't seem to do that in vb. Chris > How can you in vb.net write vbCrLf to a file without using the Use Environment.NewLine instead. If you wish, you can do> visualbasic namespace? > In C# you would just case 10/13 to char and right that. I can't seem to > do that in vb. Convert.ToChar(number) thing also. "Josip Medved" <jmed***@jmedved.com> schrieb: Both are not exactly the same as "\r\n" in C#. 'Environment.NewLine' >> How can you in vb.net write vbCrLf to a file without using the >> visualbasic namespace? > >> In C# you would just case 10/13 to char and right that. I can't seem to >> do that in vb. > > Use Environment.NewLine instead. If you wish, you can do > Convert.ToChar(number) thing also. returns the system's new line character sequence, which may differ on different operating systems. Thus the compiler cannot perform certain optimizations, which is not necessarily a disadvantage if the platform-sensitivity of the new line character sequence is required. I would also use 'ChrW' instead of 'Convert.ToChar' because it will enable the VB compiler to perform optimizations. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> > > Use Environment.NewLine instead. If you wish, you can do ChrW is part of VisualBasic namespace if I remember correctly. Question> > Convert.ToChar(number) thing also. > would also use 'ChrW' instead of 'Convert.ToChar' because it will enable the > VB compiler to perform optimizations. was "How can you in vb.net write vbCrLf to a file without using the visualbasic namespace?" "Josip Medved" <jmed***@jmedved.com> schrieb: Yep, but why would you want to write code in VB without using features of VB >> > Use Environment.NewLine instead. If you wish, you can do >> > Convert.ToChar(number) thing also. > >> would also use 'ChrW' instead of 'Convert.ToChar' because it will enable >> the >> VB compiler to perform optimizations. > > ChrW is part of VisualBasic namespace if I remember correctly. Question > was > "How can you in vb.net write vbCrLf to a file without using the > visualbasic > namespace?" if those features are superior over the features provided by the .NET Framework's class library? I am questioning the OP's goal because it does not make sense to me. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> > Yep, but why would you want to write code in VB without using features of VB I have no idea why he wants to do that. :)> if those features are superior over the features provided by the .NET > Framework's class library? I am questioning the OP's goal because it does > not make sense to me. He just said that he wants it. BTW. I would not say that it is superior. Just friendlier. Chris wrote:
> How can you in vb.net write vbCrLf to a file without using the Environment.NewLine might work for you (especially if you want it to change > visualbasic namespace? when run in a different environment some time in the future). > In C# you would just case 10/13 to char and right that. I can't seem I suspect you meant 13/10 because CR=13 and LF=10.> to do that in vb. Const CRLF As String = Chr(13) & Chr(10) Andrew "Chris" <no@spam.com> schrieb: Why would you want to use Visual Basic without actually using it?> How can you in vb.net write vbCrLf to a file without using the visualbasic > namespace? 'vbCrLf' or 'ControlChars.CrLf' are part of the Visual Basic Runtime Library. This library is always referenced in VB projects and the reference cannot be removed for good reasons. Instead of writing 'string s = "Hello\r\nWorld"' in C# you can write 'Dim s As String = "Hello" & ControlChars.CrLf & "World"' in VB without any bad implications on runtime performance. The compiler will find out that "Hello", 'ControlChars.CrLf', and "World" are constant string literals and will emit the concatenated string to the binary when compiling. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> Chris wrote:
> How can you in vb.net write vbCrLf to a file without using the Lots of good answers from others but I'll chip this in anyway:> visualbasic namespace? /Why/ do you want to do this? The only reason I can think of is that you want to avoid any dependency on Microsoft.VisualBasic.dll. Well, if you're writing in Visual Basic, you can't. The Visual Basic compiler builds code that makes calls into MS.VB and, if you go to the *tremendous* lengths required to avoid these, what you wind up with won't look /anything/ like Basic (and will probably run slower as well). > In C# you would just case 10/13 to char and right that. I can't seem to AFAIK, you can't /cast/ an integer into a character, you have to > do that in vb. /convert/ it - C wraps this up in the same syntax for you; Visual Basic doesn't. Convert.ToChar should get you close. Or CChar, of course ;-)) Regards, Phill W.
Querying a database using vb
Get value from nested class using reflection Want to know the power-2 based numbers of x OpenGL Refresh problem using CsGL with VB.NET How to disable the UAC in Vista? Resolving Type mismatch, HOW Deriving Combobox items indexes bypass security in Outlook How to keep statusStrip at the bottom of the ToolStripContainer Sub(Thing as Object) {thing = new Thing.GetType} ? |
|||||||||||||||||||||||