从字符串“”到double类型的转换无效

时间:2011-10-11 06:16:47

标签: vb.net

iam将一个文本框值(值为10:1:1)传递给一个字符串,当iam运行应用程序时,我收到以下错误“coversion from string”10:1:1“to double type is invalid”。请找到下面的代码并帮助我:(文本框值也应始终大于0)

Dim strEncrypt As String = txtData.Text

If strEncrypt > 0 Then // I am getting the error here 
    txtEncryptedData.Text = Encrypt(strEncrypt)
Else 
    MessageBox.Show(
        "Enter the Value greater then 0:")
End If

谢谢, 公羊

2 个答案:

答案 0 :(得分:2)

我相信你想要这个...

如果strEncrypt.Length> 0然后

答案 1 :(得分:1)

也许你想要:

Function Check(ByVal s As String) As Boolean
    Dim parts As String()
    parts = s.Split(":")
    If parts.Length = 0 Then
        Check = False
    Else
        Check = True
        For Each sval As String In parts
            Check = Check And Int32.Parse(sval) > 0
        Next
    End If
End Function

所以你可以像Check(txtData.Text)一样使用它。

相关问题