Convert string to int

Hi there. You might need to do a convert also to resolve the error.
For example,
CInt(“1.495,20”.Replace(“.”,“”).Replace(“,”,“”).Trim)
or
Convert.ToInt32(“1.495,20”.Replace(“.”,“”).Replace(“,”,“”).Trim)

I put in .Trim incase you have any spaces.

Another method is to extract only the digits out.
CInt(String.Concat(“1.495,20”.Where(AddressOf Char.IsDigit)))
or
CInt(System.Text.RegularExpressions.Regex.Replace(“1.495,20”, “[^0-9]”, “”))

Regards!

11 Likes