Mega Code Archive

 
Categories / Delphi / Strings
 

How to convert string to int (safe mode)

Title: How to convert string to int (safe mode) var i: Integer; newint: Integer; variab: string; // with the value newvar: string; // edited string begin newvar := ''; for i := 1 to Length(variab) do begin if (Copy(variab, i, 1) = ' ') or (Copy(variab, i, 1) = ',') or (Copy(variab, i, 1) = '$') then else newvar := newvar + (Copy(variab, i, 1) = ' '); end; // at this point you have newvar // with the numerical contents of // variab... you can select end;