如何解决此错误“无法将字符串转换为整数”? [英] How to solve this error "Can't convert String into integer"?

查看:110
本文介绍了如何解决此错误“无法将字符串转换为整数”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何解决此错误无法将字符串转换为整数?

How to solve this error "Can't convert String into integer"?

推荐答案

导致此错误的原因是您正在尝试转换字符。

例如

cause of this error is you are trying to convert characters.
for example
Convert.Int32("12a") 'error because 'a' is not an integer




Convert.Int32("12") 'successful 



你可以使用Integer.TryParse


you can use Integer.TryParse

Dim amt as Integer 
Integer.TryParse("12a", amt)



快乐编码!

:)


Happy Coding!
:)


这篇关于如何解决此错误“无法将字符串转换为整数”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆