?
Solved

String concatenation in loop is bad?

Posted on 2001-08-27
4
Medium Priority
?
273 Views
Last Modified: 2012-06-27
I have read that it is bad to do string concatenation in loops on the MSDN.  

Now i need a VB script subroutine to remove blank spaces from a character string.

E.g. input parameter is  "I am a boy"
The required output is "Iamaboy"

What is then the best technique to use?
0
Comment
Question by:leowlf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
turbosig earned 200 total points
ID: 6428252
Replace(expression, find, replacewith[, start[, count[, compare]]])

--> Replace(strText," ","")

This will search for a space and replace it.

The last 3 parameters are optional.
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 6428806
Use Trim/Ltrim/Rtrim function
e.g.
Dim MyVar
MyVar = LTrim("   vbscript ")   ' MyVar contains "vbscript ".
MyVar = RTrim("   vbscript ")   ' MyVar contains "   vbscript".
MyVar = Trim("   vbscript ")   ' MyVar contains "vbscript".
0
 
LVL 2

Expert Comment

by:turbosig
ID: 6429208
jitqanguly,

That will only remove "empty" spaces from the ends, it will not remove inner spaces.

-->  Good call though, that will allow you to not have to replace those.
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 6429312
O yeah right, my bad !!
thanks, overlooked
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question