How do I convert from a string to an integer? Here's what I tried:
Price = CInt(Int(txtPrice.Text))
I took out the Int
and I still got an exception.
How do I convert from a string to an integer? Here's what I tried:
Price = CInt(Int(txtPrice.Text))
I took out the Int
and I still got an exception.
Use
Convert.toInt32(txtPrice.Text)
This is assuming VB.NET.
Judging by the name "txtPrice", you really don't want an Integer but a Decimal. So instead use:
Convert.toDecimal(txtPrice.Text)
If this is the case, be sure whatever you assign this to is Decimal not an Integer.