Replace

J

John Smith

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.
 
R

Ray at

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-us/ado270/htm/mdamth02_11.asp and post
back if you have questions.

Ray at home
 
P

Phill. W

.. . .
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top