Foxtable(狐表)用户栏目专家坐堂 → 满足多条件,该如何合理编程?


  共有1875人关注过本帖树形打印复制链接

主题:满足多条件,该如何合理编程?

帅哥哟,离线,有人找我吗?
旭日生
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小狐 帖子:340 积分:3375 威望:0 精华:0 注册:2011/3/22 22:52:00
满足多条件,该如何合理编程?  发帖心情 Post By: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

 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110746 积分:563656 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By: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

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

 回到顶部
帅哥哟,离线,有人找我吗?
旭日生
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小狐 帖子:340 积分:3375 威望:0 精华:0 注册:2011/3/22 22:52:00
  发帖心情 Post By:2017/10/1 8:17:00 [只看该作者]

谢谢!仔细检查了窗口中的不同代码,发现不是被上述代码“拦截”了,而是被其它文本控件代码拦截了。已解决。

 回到顶部