9.3 Convert object

Description

You can convert data types with the Convert object.

List of methods/properties

NameTypeShort description
DecimalCommaPropertySpecifies wether a comma or a point is used for decimal separation
ByteMethodConverts to the data type byte
WordMethodConverts to the data type word
DwordMethodConverts to the data type dword
DoubleMethodConverts to the data type double
SwitchMethodConverts to the data type switch
StringMethodConverts to the data type string
AngleMethodConverts between different angle formats

DecimalComma

Description

If this switch is activated then a comma is used for decimal separation instead of a point. This property affects only conversion from double to string.

Syntax

1
Convert.DecimalComma

Data type

Switch

Type

Property

Example

1
2
$
Convert.DecimalComma = True

Byte

Description

Converts each data type into the data type byte.

Syntax

1
Convert.Byte(Number)

Return value

Byte

Type

Method

Parameter: Number

Description

The number which should be converted.

Data type

All

Range

0 to 255

Example

1
2
$
d[1] = Convert.Byte(v[1])

Word

Description

Converts each data type into the data type word.

Syntax

1
Convert.Word(Number)

Return value

Word

Type

Method

Parameter: Number

Description

The number which should be converted.

Data type

All

Range

-32768 to 32767

Example

1
2
$
d[1] = Convert.Word(v[1])

Dword

Description

Converts each data type into the data type dword.

Syntax

1
Convert.Dword(Number)

Return value

Dword

Type

Method

Parameter: Number

Description

The number which should be converted.

Data type

All

Range

-2147483648 to 2147483647

Example

1
2
$
d[1] = Convert.Dword("1234")
d[1] whould be at end: 1234

Double

Description

Converts each data type into the data type double.

Syntax

1
Convert.Double(Number)

Return value

Double

Type

Method

Parameter: Number

Description

The number which should be converted.

Data type

All

Range

-1.7E+308 to +1.7E+308

Example

1
2
$
f[1] = Convert.Double(v[1])

Switch

Description

Converts each data type into the data type switch.

Syntax

1
Convert.Switch(Number)

Return value

Switch

Type

Method

Parameter: Number

Description

The number which should be converted.

Data type

All

Range

0 to 1

Example

1
2
$
s[1] = Convert.Switch(v[1])

String

Description

Converts each data type into the data type string.

Syntax

1
Convert.String(Number)

Return value

String

Type

Method

Parameter: Number

Description

The number which should be converted.

Data type

All

Range

All valid numbers

Example

1
2
$
a[1] = Convert.String(v[1])

Angle

Description

Converts an angle from one format into an other. To specifiy the angle formats used you can use the angle format constants. (For a more specific description of the angle formats see Sin method of the Math object)

Syntax

1
Convert.Angle(Angle, FormatFrom, FormatTo)

Return value

Double

Type

Method

Parameter: Angle

Description

The angle which should be converted.

Data type

Double

Range

All valid angles

Parameter: FormatFrom

Description

The angle format which is currently used for the angle.

Data type

Dword

Range

1 to 4 (Constants: DEG, RAD, GRAD and RPG)

Parameter: FormatTo

Description

The angle format which shall be converted to.

Data type

Dword

Range

1 to 4 (Constants: DEG, RAD, GRAD and RPG)

Example

1
2
$
v[1] = Convert.Angle(90, DEG, RPG)
v[1] whould be at end: 64