我这样做是对的,如果是的话 [英] Am I doing this right, if statments

查看:107
本文介绍了我这样做是对的,如果是的话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我需要检查这个陈述是否适用于C家族:

Hi All,

I need to check if this statement is right in the C family it would be:

if(cbkSkipCurrentTest.Checked != True)
{
do tests
}

或如果没有点击复选框'do tests'如果跳过它们

VB版本是

or the if the check box is not clicked 'do tests' if it is skip them the
VB version is

If (cbkSkipCurrentTest.Checked = Not (True)) Then



或是


or is it

If (cbkSkipCurrentTest.Checked <> True) Then



从我的角度看它们看起来都是一样但是......

现在进入下一个问题


They both appear to be the same from my point of view but...
Now on to the next Question

If (RFcurrent > RFfreqLowCurrentHigh) Or (RFpower > RFfreqLowPwrMax) Then
                    RFtestBool = True
                    'MsgBox("Here!!")
                    If TestFailed() = True Then Exit Sub
                End If





如果我将其更改为



If I change it to

If (cbkSkipCurrentTest.Checked <> True) Then
               If (RFpower > RFfreqLowPwrMax) Then
                    RFtestBool = True
                    'MsgBox("Here!!")
                    If TestFailed() = True Then Exit Sub
                End If 
           Else

               If (RFcurrent > RFfreqLowCurrentHigh) Or (RFpower > RFfreqLowPwrMax) Then
                   RFtestBool = True
                   'MsgBox("Here!!")
                   If TestFailed() = True Then Exit Sub
               End If
           End If



这会正常工作吗?



格伦


Will that work properly?

Glenn

推荐答案

我个人倾向于选择

I personnaly tend to prefer the
If (cbkSkipCurrentTest.Checked)
   '' ...
End If






or

If Not(cbkSkipCurrentTest.Checked)
   '' ...
End If



版本。



在C#中,这将给予


version.

In C#, that would give

if (cbkSkipCurrentTest.Checked) {
   // ...
}






and

if (!cbkSkipCurrentTest.Checked) {
   // ...
}





但这可以被视为个人选择;因为Checked属性已经是一个布尔值,我没有看到将它与true或false进行比较的要点;只需按原样使用它,你就不需要了。



希望这会有所帮助:)



But this could be seen as a personnal choice; as Checked property already is a boolean value, I don't see the point to compare it to true or false; just use it as is, there is nothing more you need.

Hope this helps :)


回答第二个问题:



是的,它会正常工作。虽然它可以简化为:

Answer to second question:

Yes, it will work properly. Though it could be simplified to:
If Not(cbkSkipCurrentTest.Checked) Then
   If (RFpower > RFfreqLowPwrMax) Then
      RFtestBool = True
      'MsgBox("Here!!")
      If TestFailed() Then Exit Sub
   End If
Else
   If (RFcurrent > RFfreqLowCurrentHigh) Or (RFpower > RFfreqLowPwrMax) Then
      RFtestBool = True
      'MsgBox("Here!!")
      If TestFailed() Then Exit Sub
   End If
End If





简洁明了,恕我直言。



Which gains in conciseness and clarity, IMHO.


这篇关于我这样做是对的,如果是的话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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