如何将字符串转换为整数?这是我尝试过的:
Price = CInt(Int(txtPrice.Text))
我取出了Int
,但仍然出现异常。
最佳答案
使用
Convert.toInt32(txtPrice.Text)
这是假设 VB.NET .
从名称“txtPrice”来看,您确实不需要一个整数,而是一个小数。因此,请改用:
Convert.toDecimal(txtPrice.Text)
如果是这种情况,请确保您分配给它的任何内容都是小数而不是整数。
关于vb.net - 如何在 Visual Basic 中将字符串转换为整数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7708838/