转换为双精度(错误) [英] converting to double (error)
本文介绍了转换为双精度(错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将字符串转换为双精度
i am converting a string to double
我想提前知道将字符串转换为双精度值是否会出错.例如,如果我尝试将hello"转换为双精度值,它会给我一个错误.
i would like to know in advanced whether it would case an error to convert a string to a double. for example if i try to convert "hello" to a double, it would give me an error.
有没有办法让我提前知道转换某些东西是否会导致错误?
is there a way for me to know ahead of time whether converting something will cause an error?
推荐答案
你想要 Double.TryParse:
Dim PossibleDouble as Double
If Double.TryParse("hello", PossibleDouble) Then
''//Success!
Else
''//Not a double
End If
这篇关于转换为双精度(错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文