• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 425
  • Last Modified:

increment IP Address

Hi,

i want to increment the IP Address by constant value
e.g

10.10.0.47 + 1 = 10.10.0.48

my approach to say that:
while Edit1.Text < Edit2.Text do
begin
 Host := Edit1.Text + 1;
end;
0
aelabed
Asked:
aelabed
1 Solution
 
gandalf_the_whiteCommented:
you can divide the number into 4 parts

W.X.Y.Z

W:=10;
X:=10;
Y:=0;
Z:=47;

then you can add to the number you want any value you want

Edit1.Text := StrToInt(W)+'.'+StrToInt(X)+'.'+StrToInt(Y)+'.'+StrToInt(Z);

0
 
MethinXCommented:
This way the ip is increased as far as possible :)

W:=10;
X:=10;
Y:=0;
Z:=47;

if Z < 256 then inc(Z)
else if Y < 256 then inc(Y)
else if X < 256 then inc(X)
else if W < 256 then inc(W);

Edit1.Text := StrToInt(W)+'.'+StrToInt(X)+'.'+StrToInt(Y)+'.'+StrToInt(Z);
0
 
Lukasz LachCommented:
it should be "< 255", isn't it?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
MethinXCommented:
true 255 is the highest possible, so all less then 256 are possible.

or it should be "<= 255"
0
 
aelabedAuthor Commented:
ok, thanx, but first i should to declare w,x,y,z as integer public variables, then i should return tha value to zero after 255 in x,y,z while w < 255 , as follows:

if Z < 255 then inc(Z)
    else if Y < 255 then begin inc(Y); Z := 0; end
    else if X < 255 then begin inc(X); Y := 0; end
    else if W < 255 then begin inc(W); X := 0 end;

    Edit1.Text := IntToStr(W)+'.'+IntToStr(X)+'.'+IntToStr(Y)+'.'+IntToStr(Z);
 
but can I write the IP without points , means i need a text box as that for tha IP address in the tcp/ip properties in the control panel.
0
 
gandalf_the_whiteCommented:
you would need 4 editboxes with '.' between them
and set the values in them according to the
values in W,X,Y and Z
0
 
CleanupPingCommented:
aelabed:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
kacorretiredCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
       to accept aelabed's answer
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Some days and here is the Christmas Time. I wish good luck and good health for you all and for your loved ones

kacor
EE Cleanup Volunteer
0
 
Computer101Commented:
PAQed, with points refunded (20)

Computer101
E-E Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now