Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I need to check if this statement is right in the C family it would be:
C++
if(cbkSkipCurrentTest.Checked != True)
{
do tests
}
or the if the check box is not clicked 'do tests' if it is skip them the
VB version is
VB
If (cbkSkipCurrentTest.Checked = Not (True)) Then

or is it
VB
If (cbkSkipCurrentTest.Checked <> True) Then

They both appear to be the same from my point of view but...
Now on to the next Question
VB
If (RFcurrent > RFfreqLowCurrentHigh) Or (RFpower > RFfreqLowPwrMax) Then
                    RFtestBool = True
                    'MsgBox("Here!!")
                    If TestFailed() = True Then Exit Sub
                End If


If I change it to
VB
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
Posted
Updated 25-Apr-14 0:18am
v2

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

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

version.

In C#, that would give
C#
if (cbkSkipCurrentTest.Checked) {
   // ...
}

and
C#
if (!cbkSkipCurrentTest.Checked) {
   // ...
}


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 :)
 
Share this answer
 
Comments
glennPattonWork3 25-Apr-14 6:21am    
Thanks...
Peter Leow 25-Apr-14 6:27am    
Good advice. 5ed!
Answer to second question:

Yes, it will work properly. Though it could be simplified to:
VB
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.
 
Share this answer
 
Comments
glennPattonWork3 25-Apr-14 6:42am    
Thanks a lot, I did go through the software changing the if's from =true to Checked based on your first answer, now I have got to get the hardware working!!!
phil.o 25-Apr-14 7:54am    
You're very welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900