在VB中有没有一种有效的方法来检查字符串是否可以转换为双精度?
我目前正在尝试将字符串转换为双精度值,然后查看它是否会抛出异常。但这似乎减慢了我的应用程序。
Try
' if number then format it.
current = CDbl(x)
current = Math.Round(current, d)
Return current
Catch ex As System.InvalidCastException
' item is not a number, do not format... leave as a string
Return x
End Try
https://stackoverflow.com/questions/1172306
复制相似问题