Author Topic: ToInteger does not work for Strings  (Read 136 times)

ashesman

  • Newbie
  • *
  • Posts: 12
    • View Profile
ToInteger does not work for Strings
« on: February 16, 2017, 05:50:00 pm »
Doesn't work.... Get "Undefined function, indexer or variable or not visible" for ToInteger

Dim someString As String = "123"
Dim someInt As Integer
someInt = someString.ToInteger

Share on Facebook Share on Twitter


mc-Josh

  • Global Moderator
  • Newbie
  • *****
  • Posts: 27
    • View Profile
Re: ToInteger does not work for Strings
« Reply #1 on: February 16, 2017, 06:49:08 pm »
You need to use:

Integer.TryConvert(someString, someInt)

This will convert the string and pass it to the integer. If it fails to convert it returns false.