Vb.net Vb网络或逻辑不工作
如果我的用户在文本框中给出了11个字符或17个字符,我希望允许他保存数据。 我已经为我的vb网络表单输入编写了这段代码。但这种逻辑是行不通的。如果我删除或条件,则此代码可用于11个字符。 但是我想实现11和17个字符Vb.net Vb网络或逻辑不工作,vb.net,Vb.net,如果我的用户在文本框中给出了11个字符或17个字符,我希望允许他保存数据。 我已经为我的vb网络表单输入编写了这段代码。但这种逻辑是行不通的。如果我删除或条件,则此代码可用于11个字符。 但是我想实现11和17个字符 If (txtSSN.Text.Length <> 11 Or txtSSN.Text.Length <> 17) Then MessageBox.Show(" National ID should be 11 or 17 characters!!"
If (txtSSN.Text.Length <> 11 Or txtSSN.Text.Length <> 17) Then
MessageBox.Show(" National ID should be 11 or 17 characters!!",
"Saving Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtSSN.Focus()
Return False
End If
If(txtSSN.Text.Length 11或txtSSN.Text.Length 17)则
MessageBox.Show(“国家ID应该是11或17个字符!!”,
“保存错误”,MessageBoxButtons.OK,MessageBoxIcon.Error)
txtSSN.Focus()
返回错误
如果结束
这三个示例将起作用:
If Not txtSSN.Text.Length = 11 And Not txtSSN.Text.Length = 17 Then
MessageBox.Show("National ID should be 11 or 17 characters!!",
"Saving Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
这三个例子将起作用:
If Not txtSSN.Text.Length = 11 And Not txtSSN.Text.Length = 17 Then
MessageBox.Show("National ID should be 11 or 17 characters!!",
"Saving Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
因为它是你想要的而不是,或者因为不是(A或B)=不(A)和不(B)我实现了这个逻辑,但它不起作用。请编辑你的问题并展示你是如何实现新逻辑的。如果不是(txtSSN.Text.Length=11和txtSSN.Text.Length=17),那么你必须选择
如果不是(txtSSN.Text.Length=11或txtSSN.Text.Length=17)然后
或如果(txtSSN.Text.Length 11和txtSSN.Text.Length 17)那么
因为它是你想要的,而不是因为它(A或B)==not(A)和not(B)我实现了这个逻辑,但它不起作用。请编辑你的问题并展示你是如何实现新逻辑的。如果不是(txtSSN.Text.Length=11和txtSSN.Text.Length=17)然后你必须选择如果不是(txtSSN.Text.Length=11或txtSSN.Text.Length=17),然后
或如果(txtSSN.Text.Length 11和txtSSN.Text.Length 17),然后
非常感谢你的解决方案。您的解决方案对我的代码有效非常感谢您的解决方案。您的解决方案适用于我的代码
If Not (txtSSN.Text.Length = 11 Or txtSSN.Text.Length = 17) Then
MessageBox.Show("National ID should be 11 or 17 characters!!",
"Saving Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If