A String Manipulation Toughie

Results 1 to 5 of 5

Thread: A String Manipulation Toughie

  1. #1
    StringCheese Guest

    Default A String Manipulation Toughie

    Hi All,<BR><BR>I have a string delimited by commas. Its stored in a session variable.<BR><BR>I&#039;ve written code that loops through the string and pulls out a substring between the commas. It then &#039;prunes&#039; the string, leaving the original string, less the substring. <BR><BR>My issue is when i throw it into a loop. It runs from 1 to Request.Form.Count (the number of questions from the previous form). However, I get an error: invalid argument &#039;left&#039;. The error does NOT happen when I subtract 1 from the Count property. This doesnt help me, cause I&#039;ve lost the last value. <BR><BR>Here is the code so far:<BR><BR>strQuestIDs = "46,47,48,49,50,51,52,53,54,"<BR>intQuestID = LEN(strQuestIDs)<BR><BR>for i = 1 to 9<BR>&#039; this prunes the last comma<BR> strQuestIDs = left(strQuestIDs, intQuestID - 1)<BR> <BR> strWithoutCommas = left(strQuestIDs, (instr(1, strQuestIDs, ",") - 1))<BR> Response.Write strWithoutCommas & "<BR>"<BR> strQuestIDs = right(strQuestIDs, (len(strQuestIDs) - len(strWithoutCommas) - 1))<BR>next<BR><BR>Anyone know what im missing? thanks a million in advance - my brain hurts<BR>

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default RE: A String Manipulation Toughie

    Have you considered using split<BR><BR>anywho first try removing the last , THEN get the len.<BR><BR><BR><BR>

  3. #3
    StringCheese Guest

    Default RE: A String Manipulation Toughie

    Split... now THERES a thought<BR><BR>I&#039;m embarrassed

  4. #4
    Paully Guest

    Default Split...

    Why not put them in a array using split then loop through that...<BR><BR>At least it&#039;s a start...If I don&#039;t understand the question please let me know<BR><BR>&#060;%strQuestIDs = "46,47,48,49,50,51,52,53,54,"<BR><BR>arrValues = Split(strQuestIDs, ",")<BR><BR><BR>for i = 0 to UBOUND(arrValues)<BR>Response.Write arrValues(i) & "<BR>"<BR>next<BR><BR>%&#062;

  5. #5
    StringCheese Guest

    Default RE: Split...

    please read above reply :)

Posting Permissions

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