Кидаем на форму Edit и нопочку. По нажатию на кнопку копируем это:
| Код | procedure TForm1.Button1Click(Sender: TObject); var a : string; i1,i2,i3,i4 : string; s1,s2,s3,s4 : integer; begin a := Form1.Edit1.Text; i1 := copy(a,0,3); if pos('.',i1) <> 0 then i1 := copy(i1,0,pos('.',i1)-1); i2 := copy(a,pos('.',a)+1,3); if pos('.',i2) <> 0 then i2 := copy(i2,0,pos('.',i2)-1); a := copy(a,pos('.',a)+1,length(a)-pos('.',a)+1); a := copy(a,pos('.',a)+1,length(a)-pos('.',a)+1); i3 := copy(a,0,3); if pos('.',i3) <> 0 then i3 := copy(i3,0,pos('.',i3)-1); i4 := copy(a,pos('.',a)+1,3); if pos('.',i4) <> 0 then i4 := copy(i4,0,pos('.',i4)-1); s1 := strtoint(i1); s2 := strtoint(i2); s3 := strtoint(i3); s4 := strtoint(i4); if s4 < 255 then begin inc(s4); end else begin s4 := 0; if s3 < 255 then begin inc(s3); end else begin s3:=0; if s2 < 255 then begin inc(s2); end else begin s2 := 0; if s1 < 255 then begin inc(s1); end else begin ShowMessage('Больше быть не может :) //'); s4 := 255; s3 := 255; s2 := 255; end; end; end; end; i1 := inttostr(s1); i2 := inttostr(s2); i3 := inttostr(s3); i4 := inttostr(s4); Form1.Edit1.text := i1+'.'+i2+'.'+i3+'.'+i4; end;
|
P/S/ Код писал на скорую руку, сильно не пинать. |