473,508 Members | 2,303 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

which is best?

sb = New StringBuilder
sb.Append(vbNewLine)
sb.Append("function init() {")
sb.Append(vbNewLine)
sb.Append("ModuleMenu = new TRMenu.TRMenu();")
sb.Append(vbNewLine)
sb.Append("ModuleMenu.Add('Modules',0,'ModuleMenuL ist');")

Or

sb = New StringBuilder
sb.Append(vbNewLine & "function init() {" & vbNewLine & "MMenu = new
Menu.Menu();" & vbNewLine & "ModuleMenu.Add('Modules',0,'ModuleMenuList'); ")

I've been told that the first method of joining a string is definately a
better way of programming. Is this correct? To me it seems like more work to
for the same result.

Jul 21 '05 #1
4 1095
Jimbo,

I find definitly the first way much nicer, however the compiler optimizes
the second way.

I hope this helps,

Cor
Jul 21 '05 #2

"Jimbo Jim" <Ji******@discussions.microsoft.com> wrote in message
news:25**********************************@microsof t.com...
sb = New StringBuilder
sb.Append(vbNewLine)
sb.Append("function init() {")
sb.Append(vbNewLine)
sb.Append("ModuleMenu = new TRMenu.TRMenu();")
sb.Append(vbNewLine)
sb.Append("ModuleMenu.Add('Modules',0,'ModuleMenuL ist');")

Or

sb = New StringBuilder
sb.Append(vbNewLine & "function init() {" & vbNewLine & "MMenu = new
Menu.Menu();" & vbNewLine &
"ModuleMenu.Add('Modules',0,'ModuleMenuList'); ")

I've been told that the first method of joining a string is definately a
better way of programming. Is this correct? To me it seems like more work
to
for the same result.

I wouldn't use a string builder for the second case ( unless you were going
to continue to append ). The string builder becomes efficient when append
is used repeatadly
Jul 21 '05 #3
Thanks for your reply.
So for instance:
s = New StringBuilder
s.Append(vbNewLine)
s.Append(vbNewLine)
s.Append("function init() {")
s.Append(vbNewLine)
s.Append("MMenu = new Menu.Menu();")
s.Append(vbNewLine)
s.Append(vbNewLine)
s.Append("MMenu.Add('Modules',0,'MMenuList');")
If something Then
s.Append(vbnewline)
s.Append("and add this:")
s.Append("then this")
End If

Runs better like this:

s = New StringBuilder
s.Append(vbNewLine & "function init() {" & vbNewLine & "MMenu = new
Menu.Menu();" & vbNewLine & "ModuleMenu.Add('Modules',0,'ModuleMenuList'); ")

If something Then s.Append(vbnewline & "and add this: then this")

The reason I ask is that our .Net programmer had created a program that I'm
guessing has way to many ".Appends" when they are not needed. I could
probably reduce the amount of code by a few houndred lines.

"Cor Ligthert" wrote:
Jimbo,

I find definitly the first way much nicer, however the compiler optimizes
the second way.

I hope this helps,

Cor

Jul 21 '05 #4
Jimbo,

The used time is almost the same and in think that the best is in the
middle.
Just my idea

Cor
Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4206
by: CY FOK | last post by:
Hi I am planning to open a software company to develop client-server apps and web applications for my client. Now, i am in a difficult situation to determine what is the best platform i should use...
1
4107
by: JJ | last post by:
Hi, I was going to buy a server with Raid 1 as I thought that it meant that if one of the two mirrored drives fail, you simply take it out and put a new one in. At which point presumably the...
3
1378
by: Balaji Kannan | last post by:
Hi, In dot net during component development i have used some member variables in the class file. Inside the class i have used the member declaration and the instant handling in the following...
17
3941
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher ...
34
10766
by: Jeff | last post by:
For years I have been using VBA extensively for updating data to tables after processing. By this I mean if I had to do some intensive processing that resulted in data in temp tables, I would have...
24
2826
by: invitro81 | last post by:
Hello I've recently learnt python and I do love it! I congratulate all those geeks who produce this nice language; well, because I could be called a nearby newbee I've decided to improve my...
3
1603
by: ram_palavalasa | last post by:
Hi all, Whichone is the best among the following while proessing the data? ODBC,DAO,ADO,OLEDB...please justify urself why ? also let me know how to loas dll component to the workspace in...
16
1813
by: John Salerno | last post by:
My initial feeling is that concatenation might take longer than substitution, but that it is also easier to read: def p(self, paragraph): self.source += '<p>' + paragraph + '</p>\n\n' vs. ...
5
2639
nehashri
by: nehashri | last post by:
hi can ne1 plz guide me as to which interface is best for posgresql. i have started using posgrsql recently. i am making a biological database which has a frontend allowing the user to select...
103
6739
by: Tom | last post by:
How do we get out of the browser infinite loop quicksand when we navigate to web pages designed to lock us in and force us to hit the "pay me" button (whatever they want to force you to do)? ...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7120
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.