Wrox Programmer Forums
|
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 3rd, 2005, 12:49 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default replace for vbnewline

hi all..

this is rather simple.. but i cannot find it anywhere.. im looking for the .net replace for vbnewline constant... i know i can use it, but that implies to add the microsoft.visualbasic reference to project and i think there should be a .net replace for that..

anybody know what is???

I can build a constant that carry the chr(13) & chr(10), but there is no one pre-defined???

HTH

Gonzalo
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old May 3rd, 2005, 02:06 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

vbCrLf = 0d 0a
vbCR = 0d
vbLF = 0a

Chr$(13) (a better choice than Chr(13)) = 0d
Chr$(10) = 0a
 
Old May 3rd, 2005, 06:55 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Or better... let the framework tell you what the character(s) should be on the environment that is running the framework with

Environment.NewLine

-Peter
 
Old May 4th, 2005, 08:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

that was what i was looking for.. thanks Peter...

HTH

Gonzalo
 
Old May 21st, 2005, 03:53 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:Originally posted by planoie
 let the framework tell you what the character(s)..
Environment.NewLine
Environment.NewLine is nothing more than a constant string like "\r\n"
in some controls "\r" or "\n" is sufficent for a newline,
in textfiles you should have "\r\n" for that.

_____________
Mehdi.
software student.
 
Old May 22nd, 2005, 07:38 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Yes mehdi, but the original question was "im looking for the .net replace for vbnewline". That is Environment.NewLine.

Plus, there are some schools of thought that say you should avoid creating literal strings wherever possible. When you create a literal string in the code, the compiler has to create some internal variable to represent that literal so it can use it. An empty string ("") can also be String.Empty. String.Empty already exists in memory as part of the loaded assemblies of .NET. "" has to be created. If you have lots of them around, you are hurting performance (granted it's pretty minimal, but add up lots of those...). Why not use what .NET has provided.

-Peter
 
Old May 31st, 2005, 12:02 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Peter,

Contemplating between the compiler having to create an internal artifact, and the program having to follow a reference to a section of memory which can be shared by all, it would seem that the drawbacks are similar, but are in different locations.
In the first, compilation takes longer, but in the other execution does.

Of course, in the case of a constant, the compiler will just insert the literal characters into the code anywhere the constant is referred to.

Thoughts?

Brian
 
Old May 31st, 2005, 12:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Allways prefer compilation to be slower that execution.. but if you put a constant that after is replace in every part of the code, just like c++ inline function, wouldn't that hurt executable len???

then if you have just some space for your program (like a lot of app. I work in) you will slower the execution to grab a couple of KB!

anyway, i dont think that actual system will be harm by any of the methods...

and im happy i made a nice q. and put you all to think a little ;)

HTH

Gonzalo
 
Old May 31st, 2005, 03:50 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

> . . . but if you [use] a constant that after[ward] is replace[d] in every part of the code,
> just like c++ inline function, wouldn’t that hurt executable len???”

Well, not for the first instance. After all, the literal string still needs to be stored somewhere in the executable.
I presume that the savings after that would be along the lines of <length of string> - <len of code req’d to deref. a var>

> Then if your app takes more memory, you would be slowing the app just to gain a few KB (paraphrased).

I don’t think that is true. My understanding is that, within the same memory page, moving the program pointer 30KB takes exactly as long as moving it 1 byte. The same with the memory pointer.


I agree that faster execution is always to be preferred over faster compilation.
But I got the idea from what Peter had to say that there might be more to the picture.
I’m looking forward to here what he has to say on this.


Regarding your original question, you also can continue to use the VB6 constants (including vbCR), if you import Microsoft.VisualBasic. :-]
 
Old June 1st, 2005, 09:10 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Brian,

Please don't be mislead that I have a clue what I'm talking about. ;)

I did a small test, granted a not very scientific one. I ran two scenarios:

        For i = 0 To intIterations - 1
            strEmpty = ""
        Next

        For i = 0 To intIterations - 1
            strEmpty = String.Empty
        Next

I had to get the number of interations into the range of 500,000,000 to get a noticable difference. And even then, neither seemed to perform better than the other. In fact they jumped back and forth between each other. I think the difference is so minimal that it's even hard to measure.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace In c# jayanth_nadig SQL Language 2 July 3rd, 2006 03:25 AM
replace ' and " with \' and \" Brian Campbell XSLT 4 May 24th, 2006 10:49 AM
replace "." with "/" thelos Excel VBA 1 September 14th, 2005 10:47 AM
Replace crmpicco VB How-To 15 May 20th, 2005 01:34 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.