SysUtils.EConvertError

From RAD Studio VCL Reference
Jump to: navigation, search

Contents

Delphi Information

From SysUtils.pas

EConvertError = class(Exception)


Unit: SysUtils

Type: class

Inherited Class Members: SysUtils.EConvertError Members

C++ Information

From SysUtils.hpp

EConvertError = class(Exception)


Unit: SysUtils

Type: class

Inherited Class Members: SysUtils.EConvertError Members

Class Constructors & Destructors: SysUtils.EConvertError Constructors

Description

EConvertError is the exception class for string and object conversion errors.


EConvertError is raised when:

  • An application makes an unsuccessful attempt to convert an integer, float, date, or time to a string, or to convert a string to one of these other types.
  • An application passes an invalid argument to a formatting routine.
  • An application attempts to assign one type of component derived from TPersistent to another component derived from TPersistent when such an assignment is not possible. For example, EConvertError is raised by the attempted assignment of a TButton control to a TEdit control.

In the examples below, an EConvertError exception is raised on the attempt to convert a String to a TDateTime and the date in the String is invalid. The type of exception and the error message are displayed.

//Delphi example

const LF = #10; var TempDate: TDateTime; begin try TempDate := StrToDateTime('99/99/1998'); except on E: EConvertError do ShowMessage(E.ClassName + LF + E.Message);

end;

//C++ example

TDateTime TempDate; try { TempDate = StrToDateTime("99/99/1998"); } catch (EConvertError &E) { ShowMessage(AnsiString(E.ClassName()) + "\n" + AnsiString(E.Message)); }

See Also

Code Samples


Personal tools
Translations
Newest Version