Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Replace

Reply
Thread Tools

Replace

 
 
John Smith
Guest
Posts: n/a
 
      10-23-2003
Hi,

Just wanted to check that I'm doing things the right way..........

I need to create a string along the lines of "23,43,78,23" with no comma at
the beginning or end of it. The data comes out of a table so i've created a
loop to get the data and form the string :

StrRecip = "," & objRS("number") & StrRecip

This will give me something like : ",42,78,67,2,90"

And then I've removed the leading comma :

StrRecipRem = replace(StrRecip, ",", "", 1, 1)

Is there actually a better way ?

Thanks

J.





 
Reply With Quote
 
 
 
 
Ray at
Guest
Posts: n/a
 
      10-24-2003
That'll work, or you can do something like right(var, len(var) - 1). It'll
all be about the same. Another thing that you may want to look at though is
the getstring method of the recordset object. If you are only pulling in
the "number" column in your recordset, you can grab all the values at once
from the recordset with them all comma delimited, then close and destroy the
rs immediately without having to loop through it. Take a look here,
http://msdn.microsoft.com/library/en...damth02_11.asp and post
back if you have questions.

Ray at home

"John Smith" <(E-Mail Removed)> wrote in message
news:bn8rs5$ii3$(E-Mail Removed)...
> Hi,
>
> Just wanted to check that I'm doing things the right way..........
>
> I need to create a string along the lines of "23,43,78,23" with no comma

at
> the beginning or end of it. The data comes out of a table so i've created

a
> loop to get the data and form the string :
>
> StrRecip = "," & objRS("number") & StrRecip
>
> This will give me something like : ",42,78,67,2,90"
>
> And then I've removed the leading comma :
>
> StrRecipRem = replace(StrRecip, ",", "", 1, 1)
>
> Is there actually a better way ?
>
> Thanks
>
> J.
>
>
>
>
>



 
Reply With Quote
 
 
 
 
Phill. W
Guest
Posts: n/a
 
      10-24-2003
"John Smith" <(E-Mail Removed)> wrote in message
news:bn8rs5$ii3$(E-Mail Removed)...
.. . .
> I need to create a string along the lines of "23,43,78,23" with no
> comma at the beginning or end of it. The data comes out of a table
> so i've created a loop to get the data and form the string :

.. . .
> This will give me something like : ",42,78,67,2,90"
>
> And then I've removed the leading comma :


StrRecipRem = Mid( StrRecip, 2 )

HTH,
Phill W.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace /n with a XHTML <br /> using string.replace Alun ASP .Net 3 02-18-2008 05:52 AM
Re: [Pyrex] pyrex functions to replace a method (Re: replace a method Greg Ewing Python 2 06-29-2006 05:25 PM
pyrex functions to replace a method (Re: replace a method in class:how?) Brian Blais Python 1 06-27-2006 12:13 PM
s/$match/$replace/ fails when $replace has backreferences anonyusenet@yahoo.com Perl Misc 3 09-12-2005 11:03 AM
help with string replace - for doing selective replace Prasad S Javascript 2 08-27-2004 03:22 PM



Advertisments