Counting commas in a string

Results 1 to 5 of 5

Thread: Counting commas in a string

  1. #1
    Join Date
    Dec 1969

    Default Counting commas in a string

    I need a way to sount the number of commas in a returned string<BR><BR>I use<BR><BR>myString = Request.form("someFormElement")<BR><BR>howManyComm asinmySrting = ?????????<BR><BR>thanks in advance for any advice

  2. #2
    Join Date
    Dec 1969

    Default RE: Counting commas in a string

    &nbsp;<BR>intCount = 0<BR>if instr(myString, ",") then<BR>&nbsp;&nbsp;&nbsp; intStart = 0<BR>&nbsp;&nbsp;&nbsp; do<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intCount = intCount + 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intStart = instr(intStart + 1, myString, ",")<BR>&nbsp;&nbsp;&nbsp; loop while intStart &#062; 0<BR>end if<BR>

  3. #3
    Steve Cimino Guest

    Default Caution: Infinate loop

    If there is at least one comma in the string, the loop will never break out. intStart will always be greater than 0.<BR><BR>It would probably be better to loop through the length of the string, or find a way to break out of the loop once all commas are accounted for.

  4. #4
    Steve Cimino Guest

    Default Never mind, I'm an idiot

    I forgot that InStr will return a 0.<BR><BR>Ahh, Monday.

  5. #5
    Join Date
    Dec 1969

    Default Items in request(element)

    myString = Request.form("someFormElement")<BR><BR>howManyComm asinmySrting <BR>= Request.form("someFormElement").Count - 1<BR><BR>

Posting Permissions

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