这段代码应该合你用。
procedure SetAddress( const Value: String );
var str: String;
begin
str := Value;
try
FFirstIPAddress := StrToInt( Copy(str, 1, Pos('.', str) - 1) );
except
FFirstIPAddress := 0;
end;
try
str := Copy( str, Pos('.', str) + 1, 255 );
FSecondIPAddress := StrToInt( Copy(str, 1, Pos('.', str) - 1) );
except
FSecondIPAddress := 0;
end;
try
str := Copy( str, Pos('.', str) + 1, 255 );
FThirdIPAddress := StrToInt( Copy(str, 1, Pos('.', str) - 1) );
except
FThirdIPAddress := 0;
end;
try
str := Copy( str, Pos('.', str) + 1, 255 );
FFourthIPAddress := StrToInt( str );
except
FFourthIPAddress := 0;
end;
end;