C# 如何在VB中检查文本框中的负值?
如何检查文本框中的负值?我只能对文本框进行三等分,以便在文本框中验证它是否为数值:C# 如何在VB中检查文本框中的负值?,c#,vb.net,visual-studio-2010,C#,Vb.net,Visual Studio 2010,如何检查文本框中的负值?我只能对文本框进行三等分,以便在文本框中验证它是否为数值: If Not Decimal.TryParse(txtParts.Text, decParts) Then If decParts <= 0 Then MessageBox.Show("ERROR: Value must be a positive number!") End If MessageBox.Show("ERROR: Value must be numer
If Not Decimal.TryParse(txtParts.Text, decParts) Then
If decParts <= 0 Then
MessageBox.Show("ERROR: Value must be a positive number!")
End If
MessageBox.Show("ERROR: Value must be numeric!")
Return False
End If
如果不是Decimal.TryParse(txtParts.Text,decParts),则
If decParts您的If
条件基本上是说它是否没有成功地将其解析为一个数字。你想要的是:
If Decimal.TryParse(txtParts.Text, decParts) Then
If decParts <= 0 Then
MessageBox.Show("ERROR: Value must be a positive number!")
Return False
End If
Else
MessageBox.Show("ERROR: Value must be numeric!")
Return False
End If
如果是Decimal.TryParse(txtParts.Text,decParts),则
If decParts您的If
条件基本上是说它是否没有成功地将其解析为一个数字。你想要的是:
If Decimal.TryParse(txtParts.Text, decParts) Then
If decParts <= 0 Then
MessageBox.Show("ERROR: Value must be a positive number!")
Return False
End If
Else
MessageBox.Show("ERROR: Value must be numeric!")
Return False
End If
如果是Decimal.TryParse(txtParts.Text,decParts),则
如果DecPart