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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculations on an IP address. 1

Status
Not open for further replies.

Cendanthit

Technical User
Dec 28, 2004
2
US
I would like to calculate on the last series of numbers of an IP address. The field is a text field.

example: 10.00.000.001 is my IP address. I would like to add 10 to the IP. to make it 10.00.000.011.

Another catch is I would like to keep the format and the IP addresses change so I can’t just truncate the field.

I am using Crytal 9.

Can anyone help me with this conundrum?
 
Will the IP address always be the same length?

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
askdon@srhconsulting.com
 
Are there always 3-digits after the last "."? What would you want to happen if the address was: 10.00.000.2? The following might work for you:

left({table.IP},instrrev({table.IP},".")) + totext(val(mid({table.IP},instrrev({table.IP},".")+1))+10,replicatestring("0",len(mid({table.IP},instrrev({table.IP},".")+1))))

But please note that while this works fine if there are at least two digits in the last series, it would change 10.00.000.2 to 10.00.000.12, and I'm not sure that's what you want.

-LB
 
Thanks LB

I have to do a bit more testing but I think your formula is what I am looking for.

Thanks

RV
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top