Convert String to Double - VB

前端 未结 5 1688
长发绾君心
长发绾君心 2020-12-01 23:41

Is there an efficient method in VB to check if a string can be converted to a double?

I\'m currently doing this by trying to convert the string to a double and then

5条回答
  •  执念已碎
    2020-12-01 23:58

    Dim text As String = "123.45"
    Dim value As Double
    If Double.TryParse(text, value) Then
        ' text is convertible to Double, and value contains the Double value now
    Else
        ' Cannot convert text to Double
    End If
    

提交回复
热议问题