473,569 Members | 2,691 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 #1
16 1549

"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
Any = Or
All = And

your statement wants all the conditions to be met before the exit will
occur.

LS

Oct 29 '08 #2
Did you want an OR connector instead of AND?
You said: should catch if ANY of the conditions are met

Would
If (not boolDSIFlushGap Reading) OR (muxClass.DSIVa lues.Count < 2) OR
(muxClass.COM1A ctive <1) Then

do it?

"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

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 #3
On Wed, 29 Oct 2008 10:20:57 -0700 (PDT), cmdolcet69
<co************ @hotmail.comwro te:
>I have the below if statement, that should catch if any of the
conditions are met.....however for some reasons if my
boolDSIFlushGa pReading = true and MuxClass.DSIVal ues.count =1 and my
muxclass.COM1A ctive =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
Your statement says to execut the Exit Sub only if all three
conditions are met. In your example the first one is not met and the
other two are.

Apparently you want Or instead of And. An Or test is true if either
item is true, and And test is true of both items are true.

Also, you should use AndAlso and OrElse instead of And and Or for
tests like this.
Oct 29 '08 #4
On Oct 29, 1:39*pm, Jack Jackson <jjack...@cinno vations.netwrot e:
On Wed, 29 Oct 2008 10:20:57 -0700 (PDT), cmdolcet69

<colin_dolce... @hotmail.comwro te:
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

Your statement says to execut the Exit Sub only if all three
conditions are met. *In your example the first one is not met and the
other two are.

Apparently you want Or instead of And. *An Or test is true if either
item is true, and And test is true of both items are true.

Also, you should use AndAlso and OrElse instead of And and Or for
tests like this.

Ok a step further lets say:
boolDSIFlushGap Reading = true and MuxClass.DSIVal ues.count =1 and my
muxclass.COM1Ac tive =2 it will not exit the program???

How can I fix that.......
Oct 29 '08 #5
On Oct 29, 1:27*pm, "Lloyd Sheen" <sql...@hotmail .comwrote:
"cmdolcet69 " <colin_dolce... @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

Any = Or
All = And

your statement wants all the conditions to be met before the exit will
occur.

LS
No what happends is that DSIValues.Count can =1 but then the
muxclass.COM1Ac tive = 0
The only wat it doesn;t exist is that DSIValues.Count can =2 but then
the muxclass.COM1Ac tive = 1 or

DSIValues.Count can =1 but then the muxclass.COM2Ac tive = 2
Oct 29 '08 #6
"cmdolcet69 " <co************ @hotmail.comsch rieb
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

First I thought it could be a matter of operator precedence
(http://msdn.microsoft.com/en-us/library/fw84t893.aspx), but it's correct.

You expect the program to exit. Have you tested if the "Exit sub" statement
is reached (Debug.Print)? Or maybe it is reached but it doesn't cause the
expected behavior? Exit Sub exits the sub, not the program.
Armin

Oct 29 '08 #7
On Oct 29, 3:51*pm, "Armin Zingler" <az.nos...@free net.dewrote:
"cmdolcet69 " <colin_dolce... @hotmail.comsch rieb
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

First I thought it could be a matter of operator precedence
(http://msdn.microsoft.com/en-us/library/fw84t893.aspx), but it's correct..

You expect the program to exit. Have you tested if the "Exit sub" statement
is reached (Debug.Print)? Or maybe it is reached but it doesn't cause the
expected behavior? Exit Sub exits the sub, not the program.

Armin
Armin it never exit the Sub and that all I want it to do is exit the
sub
Oct 29 '08 #8
"cmdolcet69 " <co************ @hotmail.comsch rieb
Armin it never exit the Sub and that all I want it to do is exit the
sub

It's possible that debugging has an influence on the result, in particular
as you are handling COM ports here (I guess) where the state can change
while debugging. For example, if you set a breakpoint and examine the
values, they can be different from those if you had not interrupted the
execution. Therefore, try this:

debug.write(boo lDSIFlushGapRea ding & " ")
debug.write(mux Class.DSIValues .Count & " ")
debug.writeline (muxClass.COM1A ctive)

If boolDSIFlushGap Reading = False And muxClass.DSIVal ues.Count < 2 _
And Not muxClass.COM1Ac tive = 1 Then
debug.writeline ("exit sub")
Exit Sub
End If
I can not debug it here, so maybe exit sub is reached but the function is
called again and you think it is never left? I don't know. Is "exit sub"
ever shown in the debug/output window? Do you ever get the value combination
that you think should make the sub exit?

Armin

Oct 29 '08 #9
On Wed, 29 Oct 2008 11:38:16 -0700 (PDT), cmdolcet69
<co************ @hotmail.comwro te:
>On Oct 29, 1:39*pm, Jack Jackson <jjack...@cinno vations.netwrot e:
>On Wed, 29 Oct 2008 10:20:57 -0700 (PDT), cmdolcet69

<colin_dolce.. .@hotmail.comwr ote:
>I have the below if statement, that should catch if any of the
conditions are met.....however for some reasons if my
boolDSIFlushGa pReading = true and MuxClass.DSIVal ues.count =1 and my
muxclass.COM1A ctive =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

Your statement says to execut the Exit Sub only if all three
conditions are met. *In your example the first one is not met and the
other two are.

Apparently you want Or instead of And. *An Or test is true if either
item is true, and And test is true of both items are true.

Also, you should use AndAlso and OrElse instead of And and Or for
tests like this.


Ok a step further lets say:
boolDSIFlushGa pReading = true and MuxClass.DSIVal ues.count =1 and my
muxclass.COM1A ctive =2 it will not exit the program???

How can I fix that.......
I don't understand what behavior you want.

In the example above, it would not exit because only one of the
conditions is true, and when you use And all must be true.

If you use Or, then if any condition is true it will exit, so in your
example above if you changed the Ands to Ors (or preferrably OrElse)
it would exit since muxClass.DSIVal ues.Count is < 2.
Oct 29 '08 #10

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

Similar topics

28
3548
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...
26
14121
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
3501
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...
1
66857
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
6100
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
4995
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...
12
18260
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
1184
by: rohitkishoregupta | last post by:
Hi, Table A Col1 Col2 Col3 Col4 Table B Col5 Both tables are not linked to each other.
0
7695
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8119
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...
1
7668
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...
0
7964
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...
0
6281
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5509
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...
0
5218
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...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
936
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...

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.