Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Location
    London
    Posts
    341

    Unanswered: concatenate a string

    Ok a slightly odd question, but what I need to know is how to concatenate a string.

    I have a string of numbers which could range from 10 to perhaps 255 characters (probably more).

    Lets say I have a 10 character string which is "0123456789"

    What I would like to be able to do is concatenate this at every 3rd interval so I achieve

    012 345 678 9

    Is this possible and does someone have a solution?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    write a function that chops the string into ndigit elements
    ..should be something similar to:-

    Code:
    public function PadString (strString as String, NoChars as integer) as string
    dim NoItertations as integer 'this will be the number of times we go through the source
    PadString = "" 'will be the return value from the function
    NoIterations = length(strString)\NoChars 'find out how many iterations there are in the source
    for iLoop = 1 to NoIterations step NoChars
      PadString = padString & mid(strString, iLoop, iLoop+NoChars) & " "
    next iLoop
    end function
    but the above is untested, unporven air code, just made up on the fly
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Oct 2003
    Location
    London
    Posts
    341
    On the fly? amazing...

    It looks ok but can you explain what 'NoChars' is?

  4. #4
    Join Date
    Oct 2003
    Location
    London
    Posts
    341
    Healdem sorry I figured it meant 3 but couldn't be sure.

    Your function works perfectly with the exception of

    Code:
    ...strString, iLoop, iLoop+NoChars) & " "
    With this it seemed to exponentially grow... i.e. the first group was 4 letters long, then it was 7 then it was 10...

    I adjusted iLoop + NoChars and it worked so thank you!

    Code:
    ...strString, iLoop, NoChars) & " "

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •