Option strict on disallows implicit conversion from integer to string

I have here a very simple action being performed on a string.

Why does Cint not work for converting string to integer? I have read in previous posts that in some “For each” loops that the variable should be converted to a string first. But I am just getting that the conversion from integer to string is not allowed.practice.xaml (5.1 KB)

Hi @mia.tong

You need to have a second variable of type Int32 for this to work. Right now you are trying to assign the converted Integer to a String type variable “Price” :slight_smile:

Hi, in your code you are trying to assign to “Price” (a string) the Cint result (which is an integer

instead you need to define a Int32 and assign to that, if you want an integer, but as your sample is 9.99 you might want to make that new variable a Double and adjust the code

something like this

Variable DblPrice is “Double” type
Assign to DblPrice = CDbl(Price.Remove(0,1).Trim)

sorry @mia.tong our posts crossed :slight_smile:

1 Like