Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: VBScript/asp question...


Message #1 by Ben Greenhouse <b.greenhouse@u...> on Wed, 14 Feb 2001 19:40:24 -0500
Hi Folks



    I'm trying to do a weird "for" statement here...Basically, I have an

array (arrUsedPromotions).  I want to compare a value in another array

to all of the values in arrUsedPromotions, and if it's the same as any

one of them, then execute something...The problem is, I can't figure out

how to nest the for and next statements.  here is what I have.



for c = 0 to Ubound(arrUsedPromotions, 2)

     if arrRewards(3,b) = arrUsedPromotions(0,c) then

      arrSubTotRew(1,arrUsedPromotions(1,c)) 

arrSubTotRew(1,arrUsedPromotions(1,c)) + arrRewards(0,b)

      else

      next

       RowCounter = RowCounter + 1

       Redim Preserve arrSubTotRew(4, RowCounter)

       arrSubTotRew(0,RowCounter-1) = arrRewards(3,b)

       arrSubTotRew(1,RowCounter-1) = arrRewards(0,b)

       arrSubTotRew(2,RowCounter-1) = arrRewards(1,b)

       arrSubTotRew(3,RowCounter-1) = arrRewards(2,b)

       Redim arrUsedPromotions(2, RowCounter)

       arrUsedPromotions(0, Rowcounter-1) = arrRewards(3,b)

       arrUsedPromotions(1, Rowcounter-1) = RowCounter-1

     end if



Any ideas?



Ben



Message #2 by "Ken Schaefer" <ken@a...> on Thu, 15 Feb 2001 17:33:08 +1100
You have:



For...

    If...

    Else

    Next

End if



If something falls into If... then it never sees the Next...since Next is

after Else...



How on earth did you indent things to come up with the above?



I think what you wan to do is something like:



For i = 0 to UBound(arrToCheck)



    blnFlag = 0



    For j = 0 to UBound(ArrToMasterList)



        If CStr(arrMasterList(j) - CStr(arrToCheck(i)) then



            blnFlag = 1

            Exit For



        End if



    Next



    If blnFlag = 1 then

        ' Execute stuff

    End if



' Repeat Process with next element of array

Next



Cheers

Ken





----- Original Message -----

From: "Ben Greenhouse" <b.greenhouse@u...>

To: "ASP Databases" <asp_databases@p...>

Sent: Thursday, February 15, 2001 11:40 AM

Subject: [asp_databases] VBScript/asp question...





> Hi Folks

>

>     I'm trying to do a weird "for" statement here...Basically, I have an

> array (arrUsedPromotions).  I want to compare a value in another array

> to all of the values in arrUsedPromotions, and if it's the same as any

> one of them, then execute something...The problem is, I can't figure out

> how to nest the for and next statements.  here is what I have.

>

> for c = 0 to Ubound(arrUsedPromotions, 2)

>      if arrRewards(3,b) = arrUsedPromotions(0,c) then

>       arrSubTotRew(1,arrUsedPromotions(1,c)) 

> arrSubTotRew(1,arrUsedPromotions(1,c)) + arrRewards(0,b)

>       else

>       next

>        RowCounter = RowCounter + 1

>        Redim Preserve arrSubTotRew(4, RowCounter)

>        arrSubTotRew(0,RowCounter-1) = arrRewards(3,b)

>        arrSubTotRew(1,RowCounter-1) = arrRewards(0,b)

>        arrSubTotRew(2,RowCounter-1) = arrRewards(1,b)

>        arrSubTotRew(3,RowCounter-1) = arrRewards(2,b)

>        Redim arrUsedPromotions(2, RowCounter)

>        arrUsedPromotions(0, Rowcounter-1) = arrRewards(3,b)

>        arrUsedPromotions(1, Rowcounter-1) = RowCounter-1

>      end if

>

> Any ideas?

>

> Ben





Message #3 by Peter Zahos <pzahos@s...> on Thu, 15 Feb 2001 14:52:50 +0800
arr1

arr2



	for c = 0 to (size of arr1)

		for x = 0 to (size of arr2)

			if arr1(c) = arr2(x) then

				execute something (function)

			else

				do nothing

			end if

		next

	next



1.	arr1 will intially drop into it's first value.

2.	then arr2 will loop around comparing values to the first value in

arr1.

3.    after arr2 has finished looping, arr1 will drop into it's second

value.

4.    ...and arr2 goes through it's entire loop again

5.	this continues until arr1 has looped through entirely.



Basically arr2 will loop through all of it's values for every record in

arr1.



-----Original Message-----

From: Ben Greenhouse [mailto:b.greenhouse@u...]

Sent: Thursday, 15 February 2001 8:40 AM

To: ASP Databases

Subject: [asp_databases] VBScript/asp question...





Hi Folks



    I'm trying to do a weird "for" statement here...Basically, I have an

array (arrUsedPromotions).  I want to compare a value in another array

to all of the values in arrUsedPromotions, and if it's the same as any

one of them, then execute something...The problem is, I can't figure out

how to nest the for and next statements.  here is what I have.



for c = 0 to Ubound(arrUsedPromotions, 2)

     if arrRewards(3,b) = arrUsedPromotions(0,c) then

      arrSubTotRew(1,arrUsedPromotions(1,c)) 

arrSubTotRew(1,arrUsedPromotions(1,c)) + arrRewards(0,b)

      else

      next

       RowCounter = RowCounter + 1

       Redim Preserve arrSubTotRew(4, RowCounter)

       arrSubTotRew(0,RowCounter-1) = arrRewards(3,b)

       arrSubTotRew(1,RowCounter-1) = arrRewards(0,b)

       arrSubTotRew(2,RowCounter-1) = arrRewards(1,b)

       arrSubTotRew(3,RowCounter-1) = arrRewards(2,b)

       Redim arrUsedPromotions(2, RowCounter)

       arrUsedPromotions(0, Rowcounter-1) = arrRewards(3,b)

       arrUsedPromotions(1, Rowcounter-1) = RowCounter-1

     end if



Any ideas?



Ben




  Return to Index