六分之一/六分之一? [英] Six of One / Half Dozen Of Another?

查看:77
本文介绍了六分之一/六分之一?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在线的mysql数据库,正在通过C ++访问.如果我执行版本1或版本2,会有区别吗?我知道语法和其他内容已经关闭,但是我只是在尝试获取框架...欢迎任何建议....

第一版

I have an online mysql Database that I am accessing through C++. Is there a difference if I do Version 1 or Version 2? I know thw syntax and other stuff is off, but I''m just trying to get the framework...Any suggestions are welcome....

FIRST VERSION

Field 1 = DCount("IP", "tblURLIP", "IP = 192.168.1.168")
Field 2 = DCount("IPStatus", "tblURLIP", "IP = 192.168.1.168 And IPStatus = 1")
Field 3 = DLookUp("IPMax", "tblURLIP", "IP = 192.168.1.168")
Field 4 = DSum("IPDown", "tblIPAccess", "IP = 192.168.1.168")

If Field 4 <= Field 3 Then
Field 5 = 1
Else
Field 5 = 0
End If

If Field 1 + Field 2 + Field 5 = 3 Then
"Proceed"
Else
"Quit"
End If


第二版


SECOND VERSION

Field 1 = DCount("IP", "tblURLIP", "IP = 192.168.1.168")
Field 2 = DCount("IPStatus", "tblURLIP", "IP = 192.168.1.168 And IPStatus = 1")
Field 3 = DLookUp("IPMax", "tblURLIP", "IP = 192.168.1.168")
Field 4 = DSum("IPDown", "tblIPAccess", "IP = 192.168.1.168")

If Field 1 = 1 Then
 If Field 2 = 1 Then
	If Field 3 <= Field 4 Then
	  "Proceed"
        Else
	  "Quit"
	End If
 Else
 	"Quit"
 End If	
Else
  "Quit"
End If

推荐答案

如何:

How about:

if(Field1 != 1 || Field2 != 1 || Field3 > Field4)
    "Quit"
else
    "Proceed"



这样,一旦发现其中一个条件失败,便可以退出,并且不需要多个(单独的)if语句.
我建议不要使用If Field 1 + Field 2 + Field 5 = 3 Then之类的东西,即使您非常确定将来将来发生某些更改时该字段将是什么,您也可能会遇到一些意外的行为,例如,如果Field1 = 2,Field2 = 0和Field5 = 1仍然会通过.



That way as soon as you find out one of the conditions fails you can quit, and you won''t need multiple (separate) if statements.
I''d advise against using something like If Field 1 + Field 2 + Field 5 = 3 Then, even if your quite sure of what the fields will be if something changes in the future you might end up with some unexpected behaviour, like if Field1 = 2, Field2 = 0 and Field5 = 1 it would still go through.


这篇关于六分之一/六分之一?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆