Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difference between 2 numbers

Status
Not open for further replies.

bryand34

MIS
Nov 26, 2002
3
0
0
US
Can anyone give me some direction in the following
I want to find the difference between numbers and then save the difference to a new table. For example,

198.50.15 - 20 (sample number)
I want to be able to present this output
192.50.15
192.50.16
192.50.17
192.50.18
192.50.19
192.50.20

and send the 6 new lines to a new table.

Any help would be appreciated. Thanks.
 
The best way to do this would be to store the three parts of these numbers in separate fields. Then it would make the task a lot easier. Come to think of it, if you describe your tables (actually, list the fields) we might be able to rationalize the data scheme you're using---it sounds like it's not particularly normalized.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developers' section of the site for some helpful fundamentals.
 
actually these look like ip addresses, which are quite reasonably saved in the format shown, although they are also often store with forcing each group to three cahracters. As to the increnemtal values, I can supply a routine for that part. In this incarnation, you would need to call it in a loop and check for the final value:

Code:
Public Function basIncrIp(Ip As String) As String

    'Michael Red    12/10/2002  Tek-Tips thread702-424337

    'Example Usage
    '? basincrip("198.50.15")
    '198.50.16

    '? basincrip("198.50.99")
    '198.51.00

    Dim Idx As Integer
    Dim strPi As String
    Dim NewIp As String
    Dim MyChr As String * 1
    Dim MyVal As Integer
    Dim PrevChr As String * 1
    Dim CarryFlg As Boolean
    Dim DoneFlg As Boolean

    strPi = StrReverse(Ip)

    Idx = 1
    Do While Idx <= Len(strPi)

        MyChr = Mid(strPi, Idx, 1)
        CarryFlg = False

        If (Not DoneFlg) Then

            If (IsNumeric(MyChr)) Then

                If (MyChr < 9) Then
                    MyChr = MyChr + 1
                    DoneFlg = True
                 Else
                    MyChr = &quot;0&quot;
                    CarryFlg = True
                End If

            End If

        End If

        NewIp = NewIp & MyChr
        Idx = Idx + 1


    Loop

    basIncrIp = StrReverse(NewIp)

End Function
MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top