且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Visual Basic 中将字符串转换为整数?

更新时间:2022-11-19 16:47:31

使用

Convert.toInt32(txtPrice.Text)

这是假设 VB.NET.

从名称txtPrice"来看,您确实不想要整数而是小数.所以改为使用:

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.