以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  满足多条件,该如何合理编程?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=107571)

--  作者:旭日生
--  发布时间:2017/9/30 15:35:00
--  满足多条件,该如何合理编程?
希望xs录入数字为201或以上时,得到xs-200的结果,但结果却是101。说明有条件拦截。但我没明白是为什么被拦截?同时,也了解一下应用类似这样的多条件同时要满足的语句(如ElseIf XS > 101  And XS < 200 And txt2.text = "0" And txt1.text = "0" Then),编写应注意些什么?如何编写才是合理的?

 Dim XS As Integer = val(txt3.text)
If  val(txt1.text) = 1 And XS = 101 Then
    ls2("H") = XS - 100
ElseIf val(txt1.text) > 1 And XS = 101  Then
    ls2("H") = XS - 100
ElseIf XS = 101 And txt2.text = "0" And txt1.text = "0" Then
    ls2("H") = XS - 100
ElseIf   XS > 101  And XS < 200 And  val(txt1.text) = 1
    ls2("H") = XS - 100
ElseIf   XS > 101 And XS < 200 And val(txt1.text) > 1
    ls2("H") = XS - 100
ElseIf XS > 101  And XS < 200 And txt2.text = "0" And txt1.text = "0" Then
    ls2("H") = XS - 100
ElseIf XS > 200 And val(txt1.text) = 1
    ls2("H") = XS - 200
ElseIf XS > 200 And val(txt1.text) > 1
    ls2("H") = XS - 200
ElseIf XS > 200 And txt2.text = "0" And txt1.text = "0"
    ls2("H") = XS - 200
    
End If
End If

--  作者:有点蓝
--  发布时间:2017/9/30 16:19:00
--  
貌似是这个意思

Dim XS1 As Integer = val(txt1.text)
Dim XS2 As Integer = val(txt2.text)
Dim XS3 As Integer = val(txt3.text)
If XS3 >= 101 And XS3 < 200 Then
    If XS1 >= 1 OrElse XS1 = 0 AndAlso XS2 = 0 Then
        ls2("H") = XS - 100
    End If
ElseIf XS3 > 200
    If XS1 >= 1 OrElse XS1 = 0 AndAlso XS2 = 0 Then
        ls2("H") = XS - 200
    End If
End If

如果不是,请使用文字描述你的逻辑

--  作者:旭日生
--  发布时间:2017/10/1 8:17:00
--  
谢谢!仔细检查了窗口中的不同代码,发现不是被上述代码“拦截”了,而是被其它文本控件代码拦截了。已解决。