473,699 Members | 2,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

If statement not catching on conditions

I have the below if statement, that should catch if any of the
conditions are met.....however for some reasons if my
boolDSIFlushGap Reading = true and MuxClass.DSIVal ues.count =1 and my
muxclass.COM1Ac tive =1 it will not exit the program??? Why is that can
anyone help me

Urgent!!!!!!

If boolDSIFlushGap Reading = False And muxClass.DSIVal ues.Count < 2 And
Not muxClass.COM1Ac tive = 1 Then
Exit Sub
End If
Oct 29 '08
16 1560
Why are you not reading what everybody writes, but does not want to give you
the fish but tries to teach you how to catch the fish.

Here is the fish

\\\
If boolDSIFlushGap Reading = False OrElse muxClass.DSIVal ues.Count < 2 OrElse
muxClass.COM1Ac tive <1 Then
Exit Sub
End If
///

This means that if any of this tests is true, then it will Exit Sub

Do they all have to be true then it is

\\\
If boolDSIFlushGap Reading = False AndAlso muxClass.DSIVal ues.Count < 2
AndAlso
muxClass.COM1Ac tive <1 Then
Exit Sub
End If
///
Cor

"cmdolcet69 " <co************ @hotmail.comwro te in message
news:0f******** *************** ***********@m32 g2000hsf.google groups.com...
>I have the below if statement, that should catch if any of the
conditions are met.....however for some reasons if my
boolDSIFlushGap Reading = true and MuxClass.DSIVal ues.count =1 and my
muxclass.COM1Ac tive =1 it will not exit the program??? Why is that can
anyone help me

Urgent!!!!!!

If boolDSIFlushGap Reading = False And muxClass.DSIVal ues.Count < 2 And
Not muxClass.COM1Ac tive = 1 Then
Exit Sub
End If
Oct 30 '08 #11
cmdolcet69 wrote:
I have the below if statement, that should catch if any of the
conditions are met.....however for some reasons if my
boolDSIFlushGap Reading = true and MuxClass.DSIVal ues.count =1 and my
muxclass.COM1Ac tive =1 it will not exit the program??? Why is that can
anyone help me
If boolDSIFlushGap Reading = False And muxClass.DSIVal ues.Count < 2 And
Not muxClass.COM1Ac tive = 1 Then
Exit Sub
End If
This is why everyone is saying to use "or" rather than "and": you're not
translating English into computer the right way round.

English: let's have all the apples and bananas->let's have all the apples
and let's have all the bananas

Computer: (all the items where x is an apple) + (all the items where x is a
banana)

Logically, the + translates to "or", not "and".
If in doubt, write it as three separate conditions to make it obvious:

if not(boolDSIFlus hGapReading) then
exit sub
end if

if MuxClass.DSIVal ues.count < 2 then
exit sub
end if

if muxClass.COM1Ac tive <1 then
exit sub
end if

Remember the syntax is "if <booleanthen... ", so you shouldn't test boolean
values: you should treat it directly as a boolean, which is why I changed
your "If boolDSIFlushGap Reading = False" to "if
not(boolDSIFlus hGapReading)".

Also, I think that "if muxClass.COM1Ac tive <1" is easier to read than "if
Not muxClass.COM1Ac tive = 1".

HTH

Andrew
Oct 30 '08 #12
"easier to read" is open to debate (although I don't disagree), but
if Not muxClass.COM1Ac tive = 1
relies on precedence, whereas
if muxClass.COM1Ac tive <1
does not. Barely significant in this example, but it can save a lot of
headscratching in more complex cases.

"Andrew Morton" <ak*@in-press.co.uk.inv alidwrote in message
news:6m******** ****@mid.indivi dual.net...
snip <

Also, I think that "if muxClass.COM1Ac tive <1" is easier to read than
"if Not muxClass.COM1Ac tive = 1".

HTH

Andrew
Oct 30 '08 #13
I thought my threads were weird.

James, do you mean:
Not muxClass.COM1Ac tive = 1
is interpreted as:
(Not muxClass.COM1Ac tive) = 1
which would never be true, because true equates to -1, false to 0, and is
different from:
Not (muxClass.COM1A ctive = 1)

parens can be your friends...

maybe the whole problem is he should be testing for -1 instead of 1,
I don't know.

"James Hahn" wrote:
"easier to read" is open to debate (although I don't disagree), but
if Not muxClass.COM1Ac tive = 1
relies on precedence, whereas
if muxClass.COM1Ac tive <1
does not. Barely significant in this example, but it can save a lot of
headscratching in more complex cases.

"Andrew Morton" <ak*@in-press.co.uk.inv alidwrote in message
news:6m******** ****@mid.indivi dual.net...
snip <

Also, I think that "if muxClass.COM1Ac tive <1" is easier to read than
"if Not muxClass.COM1Ac tive = 1".

HTH

Andrew

Nov 3 '08 #14
No. The two expressions are equivalent. I was simply commenting that the
form
Not muxClass.COM1Ac tive = 1
relies on
muxClass.COM1Ac tive = 1
having a higher precedence than the Not. My preference is for having an
expression that doesn't rely on the default precedence rules, therefore I
would use either
Not (muxClass.COM1A ctive = 1)
which makes it explicit or (much simpler)
if muxClass.COM1Ac tive <1

So not only does it _look_ more sensible but there's some programming sense
behind the choice - just a tiny bit in this case, but possibly relevant in
more complex cases. The original code was complicated enough without the
possibility of misunderstandin g the implied precedence rules.

"Beth" <Be**@discussio ns.microsoft.co mwrote in message
news:3C******** *************** ***********@mic rosoft.com...
>I thought my threads were weird.

James, do you mean:
Not muxClass.COM1Ac tive = 1
is interpreted as:
(Not muxClass.COM1Ac tive) = 1
which would never be true, because true equates to -1, false to 0, and is
different from:
Not (muxClass.COM1A ctive = 1)

parens can be your friends...

maybe the whole problem is he should be testing for -1 instead of 1,
I don't know.

"James Hahn" wrote:
>"easier to read" is open to debate (although I don't disagree), but
if Not muxClass.COM1Ac tive = 1
relies on precedence, whereas
if muxClass.COM1Ac tive <1
does not. Barely significant in this example, but it can save a lot of
headscratchi ng in more complex cases.

"Andrew Morton" <ak*@in-press.co.uk.inv alidwrote in message
news:6m******* *****@mid.indiv idual.net...
snip <

Also, I think that "if muxClass.COM1Ac tive <1" is easier to read than
"if Not muxClass.COM1Ac tive = 1".

HTH

Andrew

Nov 3 '08 #15
so you're saying you don't like the left-to-right thing being overridden by
the precedence rules, because who remembers the precedence rules anyways (I
don't, obviously. I use parens.)

I don't know why this guy's confused, then.

"James Hahn" wrote:
No. The two expressions are equivalent. I was simply commenting that the
form
Not muxClass.COM1Ac tive = 1
relies on
muxClass.COM1Ac tive = 1
having a higher precedence than the Not. My preference is for having an
expression that doesn't rely on the default precedence rules, therefore I
would use either
Not (muxClass.COM1A ctive = 1)
which makes it explicit or (much simpler)
if muxClass.COM1Ac tive <1

So not only does it _look_ more sensible but there's some programming sense
behind the choice - just a tiny bit in this case, but possibly relevant in
more complex cases. The original code was complicated enough without the
possibility of misunderstandin g the implied precedence rules.

"Beth" <Be**@discussio ns.microsoft.co mwrote in message
news:3C******** *************** ***********@mic rosoft.com...
I thought my threads were weird.

James, do you mean:
Not muxClass.COM1Ac tive = 1
is interpreted as:
(Not muxClass.COM1Ac tive) = 1
which would never be true, because true equates to -1, false to 0, and is
different from:
Not (muxClass.COM1A ctive = 1)

parens can be your friends...

maybe the whole problem is he should be testing for -1 instead of 1,
I don't know.

"James Hahn" wrote:
"easier to read" is open to debate (although I don't disagree), but
if Not muxClass.COM1Ac tive = 1
relies on precedence, whereas
if muxClass.COM1Ac tive <1
does not. Barely significant in this example, but it can save a lot of
headscratching in more complex cases.

"Andrew Morton" <ak*@in-press.co.uk.inv alidwrote in message
news:6m******** ****@mid.indivi dual.net...
snip <

Also, I think that "if muxClass.COM1Ac tive <1" is easier to read than
"if Not muxClass.COM1Ac tive = 1".

HTH

Andrew


Nov 3 '08 #16
I don't think anyone knows why OP is confused because he never comes back to
indicate whether or not he worked it out. He just asks another question
from somewhere else in the project.

"Beth" <Be**@discussio ns.microsoft.co mwrote in message
news:BD******** *************** ***********@mic rosoft.com...
so you're saying you don't like the left-to-right thing being overridden
by
the precedence rules, because who remembers the precedence rules anyways
(I
don't, obviously. I use parens.)

I don't know why this guy's confused, then.
Nov 3 '08 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
3584
by: Fábio Mendes | last post by:
I'm sorry if it's an replicate. Either my e-mail program is messing with things or the python-list sent my msg to /dev/null. I couldn't find anything related in previous PEP's, so here it goes a very early draft for a new "assert" syntax: This was inspired in Ruby's assert syntax. I'm not familiar with Ruby at all, so the chances are that this piece of code is broken, but I think the idea is very obvious. In Ruby, assert is simply a...
26
14144
by: Joe Stevenson | last post by:
Hi all, I skimmed through the docs for Python, and I did not find anything like a case or switch statement. I assume there is one and that I just missed it. Can someone please point me to the appropriate document, or post an example? I don't relish the idea especially long if-else statements. Joe
7
3516
by: Guy Hocking | last post by:
Hi there, I have a problem in my ASP/SQL Server application i am developing, i hope you guys can help. I have a ASP form with list boxes populated by SQL tables. When a user selects a value in a list box and submits the form the value is put into a session variable and the relevant page is displayed (in accordance to one of the list boxes). The page is then displayed with the relevant SQL data. So far i have got the
1
66866
by: M Wells | last post by:
Hi All, Just wondering if anyone can tell me if you can test for multiple conditions as part of an "IF" statement in T-SQL in SQL Server 2000? ie something like: IF @merr = 1 or @merr=2 Begin SELECT statement
5
6102
by: Alvin Bruney | last post by:
Is a switch more efficient than an if statement? I observe thru the debugger that a switch statement jumps directly to its case handler where as an if statement examines all conditions sequentially. Is that a trick of the debugger or is a switch quicker by O(n).
1
5004
by: priyanka2203 | last post by:
Hi guys, I have a doubt regarding the CASE statement. It might sound silly, but me being new to DB2, it is kind of a genuine doubt. Try helping me with this.. When we use a case statement (simple-case-statement-when-clause), in this - the value of the expression prior to the first WHEN keyword is tested for equality with the value of each expression that follows the WHEN keyword. Right? Then if the search condition is true, the THEN...
12
18307
by: Karlo Lozovina | last post by:
I'm not sure if Python can do this, and I can't find it on the web. So, here it goes: try: some_function() except SomeException: some_function2() some_function3() ...
0
1188
by: rohitkishoregupta | last post by:
Hi, Table A Col1 Col2 Col3 Col4 Table B Col5 Both tables are not linked to each other.
0
8612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8880
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.