- How to convert Strings to Integer with CInt()
  - The Program
  - The Code:
  - The Source

# How to convert Strings to Integer with CInt()

## The Program

Type in two integer-like numbers. They will be added.

## The Code:

    STATIC PUBLIC SUB Main()
      hForm AS Fmain
      hForm = NEW Fmain
      hForm.show
    END

    PUBLIC SUB Button1_Click()
      x AS Integer
      x = CInt(TextBox1.Text) + CInt(TextBox2.Text)

'this throws an error if the input does not exactly
'looks like an integer!
'so better use val() if you're not sure.

      Label2.Text = CStr(x)
    END

## The Source

Download