Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Problems increasing number...


Message #1 by "SD-Studios" <info@s...> on Wed, 17 Oct 2001 19:42:52 +0200
 I've got this code for 10 fields. Code that is explained after a ' is not

included in this mail.



<%

' here we've got the connection-code and do while not objRS.EOF



' Then I have made a "dim" on num2 and set it to 0

dim num2

num2 = 0

'then ive inserted som other fields...and then here's the important part:

		If num2 mod 2 = 0 Then

		Response.Write "1"

		ElseIf num2 mod 3 = 1 Then

		Response.Write "2"

		ElseIf num2 mod 4 = 2 Then

		Response.Write "3"

		ElseIf num2 mod 5 = 3 Then

		Response.Write "4"

		ElseIf num2 mod 6 = 4 Then

		Response.Write "5"

		ElseIf num2 mod 7 = 5 Then

		Response.Write "6"

		ElseIf num2 mod 8 = 6 Then

		Response.Write "7"

		ElseIf num2 mod 9 = 7 Then

		Response.Write "8"

		ElseIf num2 mod 10 = 8 Then

		Response.Write "9"

		Else

		Response.Write "10"

		End If

' here i've inserted a code that is suppose to add +1 to num2

num2 = num2 +1

' next i've made a movenext and a loop

%>



Those are the values i get...

1, 2, 1, 4, 1, 6, 1, 2, 1, 10

Why doesn't it could like 1, 2, 3, 4, 5, 6, 7, 8, 9, 10?

--

Martin Johansson



Message #2 by "Peter Foti (PeterF)" <PeterF@S...> on Wed, 17 Oct 2001 14:33:27 -0400
I'm curious why you are trying to do it this way.  If you are just

trying to increase the number, then just do this:



<%

num2 = 0

' Start loop here

   num2 = num2 + 1

   Response.Write(num2)

' End loop here

%>





-Pete





Message #3 by "Peter Foti (PeterF)" <PeterF@S...> on Wed, 17 Oct 2001 14:43:55 -0400
To answer your question....



num2 = 0

if num2 mod 2 = 0 (0 mod 2 = 0) then response.write "1"

num2 = 1

if num2 mod 2 = 0 (1 mod 2 = 1)

if num2 mod 3 = 1 (1 mod 3 = 1) then response.write "2"

num2 = 2

if num2 mod 2 = 0 (2 mod 2 = 0) then response.write "1"

num2 = 3

if num2 mod 2 = 0 (3 mod 2 = 1)

if num2 mod 3 = 1 (3 mod 3 = 0)

if num2 mod 4 = 2 (3 mod 4 = 3)

if num2 mod 5 = 3 (3 mod 5 = 3) then response.write "4"

num2 = 4

if num2 mod 2 = 0 (4 mod 2 = 0) then response.write "1"



etc.

Do you see what is happening?  The Mod operator returns the remainder.

It should not be used the way you are trying to use it.

See my previous post for a solution.  :)



Pete






  Return to Index