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

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
1 Solution

Commented:
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

Commented:
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

Commented:
it should be "< 255", isn't it?
0

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

or it should be "<= 255"
0

Author 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

Commented:
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

Commented:
aelabed:
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

retiredCommented:
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:

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

Commented:
PAQed, with points refunded (20)

Computer101