I’m facing a issue when I try to convert string to integer:
1/ first of all, I get my value from a webpage. Always number display as “3 183” or “123 719”. Information is stored in var1 (generic).
I need to convert my var1 in order to compare it to an other variable that come from Excel (without blank).
2/ I try to remove the blank by using replace method: var1.ToString.Replace(" “,”"), but the blank character is still there
In addition, I try to convert directly by Convert.ToInt32(var1.ToString), but I get error message : “Input string was not in a correct format”
I just noticed that you’re storing var1 as type Generic and converting var1 in place. You should instead have 2 variables used. Var1 should be string and Var2 should be type integer.
Get Var1 from the webpage e.g. “3 183”. Now assign Var2 = CInt(Var1.Replace(" “,”"))
Converting the type in place while it is “Generic” is what is causing your issues