469,923 Members | 1,350 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,923 developers. It's quick & easy.

Replace

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.

Jul 19 '05 #1
2 2542
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" <jo**@smith.com> wrote in message
news:bn**********@hercules.btinternet.com...
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.


Jul 19 '05 #2
"John Smith" <jo**@smith.com> wrote in message
news:bn**********@hercules.btinternet.com...
.. . .
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.
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Craig Keightley | last post: by
6 posts views Thread by JackpipE | last post: by
15 posts views Thread by =?Utf-8?B?TWlrZSAiWU9fQkVFIiBC?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.