Replace

Discussion in 'ASP General' started by John Smith, Oct 23, 2003.

  1. John Smith

    John Smith Guest

    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.
    John Smith, Oct 23, 2003
    #1
    1. Advertising

  2. John Smith

    Ray at Guest

    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

    "John Smith" <> wrote in message
    news:bn8rs5$ii3$...
    > 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.
    >
    >
    >
    >
    >
    Ray at, Oct 24, 2003
    #2
    1. Advertising

  3. John Smith

    Phill. W Guest

    "John Smith" <> wrote in message
    news:bn8rs5$ii3$...
    .. . .
    > 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.
    Phill. W, Oct 24, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Blais
    Replies:
    1
    Views:
    373
    Bruno Desthuilliers
    Jun 27, 2006
  2. Greg Ewing
    Replies:
    2
    Views:
    342
    Dieter Maurer
    Jun 29, 2006
  3. Alun
    Replies:
    3
    Views:
    4,495
    Masudur
    Feb 18, 2008
  4. Prasad S
    Replies:
    2
    Views:
    226
    Dr John Stockton
    Aug 27, 2004
  5. Replies:
    3
    Views:
    172
    Brian McCauley
    Sep 12, 2005
Loading...

Share This Page