---
url: /flow/guide/scripting-reference/functions/conversion/strtoint.md
---

# StrToInt

## Declaration

`Function StrToInt( const S : string) : Integer;`

### Example

```pascal
procedure OnMapEvent(var Value:Variant);
var MyAmount : String
begin
MyAmount := '123';
Value := StrToInt(MyAmount); //Value will be equal to 123
end;
```

## Description

StrToInt converts a string into an integer data type. If string does not contain a integer value an error will occur.

You could use a [Try...Except](/flow/guide/scripting-reference/statements/try...except) block or [StrToIntDef](/flow/guide/scripting-reference/functions/conversion/strtointdef) to handle the error and provide a default value.
