Results 1 to 2 of 2

Thread: Looping....

  1. #1
    Join Date
    Dec 1969

    Default Looping....

    Let&#039;s say I have string of 12,23,44,21,50,30, assigned to variable called "somevar0" (i.e. somevar0 ="12,23,44,21,50,30,") <BR>and I have an array and I want to delete some values from the original string. (let&#039;s say 12,23,44,21,50,30, -&#062; 12,50,) <BR>here is the loop I used but not working <BR><BR>for i=0 to ubound(ArrList) -1 <BR>somevar&(j+1) = replace(somevar &j, ArrList(i)&",","") <BR>j=j+1 <BR>next <BR><BR>If I do this manually it works but the array size dynamically changes so that I have to use loop... <BR><BR>&#039;/// manual verification //// <BR>somevar0="12,23,44,21,50,30," <BR>somevar1= replace(somevar0, ArrList(0)&",","") <BR>somevar2= replace(somevar1, ArrList(1)&",","") <BR>somevar3= replace(somevar2, ArrList(2)&",","") <BR><BR>In this way I I can have final value I want to have...but looping is tricky... <BR>Any help. <BR><BR><BR>I keep getting VBScript compilation error. <BR>Please help me... <BR>Thanks <BR>Tom

  2. #2
    Join Date
    Dec 1969

    Default RE: Looping....

    yourSomeVars = split(somevar0,",")<BR>for i=0 to ubound(ArrList) -1 <BR> for x = 0 to ubound(yourSomeVars) - 1<BR> if yourSomeVars(x)= ArrList(i) then<BR> yourSomeVars(x) = ""<BR> end if <BR> next<BR>next<BR>newStr = ""<BR>for x = 0 to ubound(yourSomeVars) - 1<BR> if yourSomeVars(x) &#060;&#062; "" then<BR> if newStr = "" then<BR> newStr = yourSomeVars(x) <BR> else<BR> newStr = newStr & "," & yourSomeVars(x)<BR> end if<BR> end if<BR>next<BR><BR>newStr is your new string...........<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