Formula Help needed. VB

airwind
02-11-2008, 07:29 PM
for this sequence of number... 7, 10, 13, 16, 19, 22, 25, 28, 31.... +3


if i select 22 from database... how to know this number is the number in this sequence by using formula?

JPB
02-11-2008, 08:01 PM
This example uses a loop to test if the number is 7, 10, 13, 16...+3
You can drop the loop and test for a specific number only.

The Mod function returns the remainder of a number divided by another number.


Private Sub Command1_Click()
Dim x As Long
For x = 0 To 34
If x >= 7 Then
If (x - 7) Mod 3 = 0 Then
Debug.Print x & " is in range."
End If
End If
Next x
End Sub

Darius0
02-12-2008, 07:24 AM
for this sequence of number... 7, 10, 13, 16, 19, 22, 25, 28, 31.... +3


if i select 22 from database... how to know this number is the number in this sequence by using formula?

If the Sec_Number start in 0

Sec_Number = (Sel_Number -7)/3 = (22 - 7)/3 = 5

If the Sec_Number start in 1

Sec_Number = (Sel_Number -7)/3 +1= (22 - 7)/3 +1= 6

Just go backwards.;)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum