"Matt MacDonald" <ma******@hotmail.comschrieb
Hi everyone,
Maybe I'm just discovering something late that everyone else knew
already, but it caught me off guard. In the past I could do an
expression like "If 1 <= x <= 10 Then ..." to see if x was in the
numeric range 1-10. So x = 5 would evaluate to True, whereas x = 0
would evaluate to False.
Can't repro this in VB6. Expression returns True in both cases.
Well now it seems that no matter what x
is, the statement evaluates to True.
One more reason why Option Strict should be switched On. The syntax is
not valid in VB.Net because "1 <= x" is a Boolean which is not defined
in conjunction with "<= 10". A Boolean can not be compared to an Integer
value using the "<=" operator.
VB6 did implicit conversions - wanted or not, without giving a warning
or an error. Option Strict makes you think about what has to happen.
AZ 4 1225
"Armin Zingler" <az*******@freenet.dewrote in message
news:#$**************@TK2MSFTNGP03.phx.gbl...
"Matt MacDonald" <ma******@hotmail.comschrieb
>Hi everyone, Maybe I'm just discovering something late that everyone else knew already, but it caught me off guard. In the past I could do an expression like "If 1 <= x <= 10 Then ..." to see if x was in the numeric range 1-10. So x = 5 would evaluate to True, whereas x = 0 would evaluate to False.
Can't repro this in VB6. Expression returns True in both cases.
>Well now it seems that no matter what x is, the statement evaluates to True.
One more reason why Option Strict should be switched On. The syntax is
not valid in VB.Net because "1 <= x" is a Boolean which is not defined
in conjunction with "<= 10". A Boolean can not be compared to an Integer
value using the "<=" operator.
VB6 did implicit conversions - wanted or not, without giving a warning
or an error. Option Strict makes you think about what has to happen.
AZ
Amen! I hope that someday Option Strict will be the default and unavoidable.
IMHO, code quality would improve measurably.
>
Peter,
Amen! I hope that someday Option Strict will be the default and
unavoidable. IMHO, code quality would improve measurably.
I changed my mind a while ago about this. Somebody stated the point bellow
and I agree.
As Armin, You and I have seldom a problem with casting, can option strict
off be a good start point for somebody just starts learning programming,
programming is in my idea learning to use logic, not learning to know from
head every name of a property or/and method that there can be.
I know that my knowledge about teaching is most probably very low against
yours.
But I found it a good point.
Cor
"PvdG42" <pv**@toadstool.eduschreef in bericht
news:%2***************@TK2MSFTNGP06.phx.gbl...
>
"Armin Zingler" <az*******@freenet.dewrote in message
news:#$**************@TK2MSFTNGP03.phx.gbl...
>"Matt MacDonald" <ma******@hotmail.comschrieb
>>Hi everyone, Maybe I'm just discovering something late that everyone else knew already, but it caught me off guard. In the past I could do an expression like "If 1 <= x <= 10 Then ..." to see if x was in the numeric range 1-10. So x = 5 would evaluate to True, whereas x = 0 would evaluate to False.
Can't repro this in VB6. Expression returns True in both cases.
>>Well now it seems that no matter what x is, the statement evaluates to True.
One more reason why Option Strict should be switched On. The syntax is not valid in VB.Net because "1 <= x" is a Boolean which is not defined in conjunction with "<= 10". A Boolean can not be compared to an Integer value using the "<=" operator.
VB6 did implicit conversions - wanted or not, without giving a warning or an error. Option Strict makes you think about what has to happen.
AZ
Amen! I hope that someday Option Strict will be the default and
unavoidable. IMHO, code quality would improve measurably.
>>
I'm pretty sure that
If 1 <= x <= 10 Then...
Has never been valid Microsoft BASIC syntax. If it ever worked it would not
have given the correct value because at best the (1 <= x) would return -1
(True) which would always be less than 10, so any value greater or equal to 1
would return True.
SELECT CASE x
CASE 1 TO 10
CASE ELSE
END SELECT
would give you what you want, or you could use
IF 1 <= X AND X <= 10 THEN...
--
David Streeter
Synchrotech Software
Sydney Australia
"Cor Ligthert[MVP]" wrote:
Peter,
Amen! I hope that someday Option Strict will be the default and
unavoidable. IMHO, code quality would improve measurably.
I changed my mind a while ago about this. Somebody stated the point bellow
and I agree.
As Armin, You and I have seldom a problem with casting, can option strict
off be a good start point for somebody just starts learning programming,
programming is in my idea learning to use logic, not learning to know from
head every name of a property or/and method that there can be.
I know that my knowledge about teaching is most probably very low against
yours.
But I found it a good point.
Cor
"PvdG42" <pv**@toadstool.eduschreef in bericht
news:%2***************@TK2MSFTNGP06.phx.gbl...
"Armin Zingler" <az*******@freenet.dewrote in message
news:#$**************@TK2MSFTNGP03.phx.gbl...
"Matt MacDonald" <ma******@hotmail.comschrieb Hi everyone, Maybe I'm just discovering something late that everyone else knew already, but it caught me off guard. In the past I could do an expression like "If 1 <= x <= 10 Then ..." to see if x was in the numeric range 1-10. So x = 5 would evaluate to True, whereas x = 0 would evaluate to False.
Can't repro this in VB6. Expression returns True in both cases.
Well now it seems that no matter what x is, the statement evaluates to True.
One more reason why Option Strict should be switched On. The syntax is
not valid in VB.Net because "1 <= x" is a Boolean which is not defined
in conjunction with "<= 10". A Boolean can not be compared to an Integer
value using the "<=" operator.
VB6 did implicit conversions - wanted or not, without giving a warning
or an error. Option Strict makes you think about what has to happen.
AZ
Amen! I hope that someday Option Strict will be the default and
unavoidable. IMHO, code quality would improve measurably.
>
The more I think about this, it must have been back in my C++ (or maybe
earlier) days that I used this syntax. Like I said, it very seldom comes up
for me.
Thanks for all the input,
Matt
"SurturZ" <su*****@newsgroup.nospamwrote in message
news:C7**********************************@microsof t.com...
I'm pretty sure that
If 1 <= x <= 10 Then...
Has never been valid Microsoft BASIC syntax. If it ever worked it would
not
have given the correct value because at best the (1 <= x) would return -1
(True) which would always be less than 10, so any value greater or equal
to 1
would return True.
SELECT CASE x
CASE 1 TO 10
CASE ELSE
END SELECT
would give you what you want, or you could use
IF 1 <= X AND X <= 10 THEN...
--
David Streeter
Synchrotech Software
Sydney Australia
"Cor Ligthert[MVP]" wrote:
>Peter,
Amen! I hope that someday Option Strict will be the default and
unavoidable. IMHO, code quality would improve measurably.
I changed my mind a while ago about this. Somebody stated the point bellow and I agree.
As Armin, You and I have seldom a problem with casting, can option strict off be a good start point for somebody just starts learning programming, programming is in my idea learning to use logic, not learning to know from head every name of a property or/and method that there can be.
I know that my knowledge about teaching is most probably very low against yours. But I found it a good point.
Cor
"PvdG42" <pv**@toadstool.eduschreef in bericht news:%2***************@TK2MSFTNGP06.phx.gbl...
>
"Armin Zingler" <az*******@freenet.dewrote in message
news:#$**************@TK2MSFTNGP03.phx.gbl... "Matt MacDonald" <ma******@hotmail.comschrieb Hi everyone, Maybe I'm just discovering something late that everyone else knew already, but it caught me off guard. In the past I could do an expression like "If 1 <= x <= 10 Then ..." to see if x was in the numeric range 1-10. So x = 5 would evaluate to True, whereas x = 0 would evaluate to False.
Can't repro this in VB6. Expression returns True in both cases.
Well now it seems that no matter what x is, the statement evaluates to True.
One more reason why Option Strict should be switched On. The syntax is not valid in VB.Net because "1 <= x" is a Boolean which is not defined in conjunction with "<= 10". A Boolean can not be compared to an Integer value using the "<=" operator.
VB6 did implicit conversions - wanted or not, without giving a warning or an error. Option Strict makes you think about what has to happen.
AZ
Amen! I hope that someday Option Strict will be the default and
unavoidable. IMHO, code quality would improve measurably.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Eyal |
last post by:
Hey,
I would appriciate if anyone can help on this one:
I have a java object/inteface having a method with a boolean
parameter. As I'm trying to call this method from a javascript it
fails on...
|
by: Henri |
last post by:
In java for instance there's a way to use booleans as objects and not as
value types.
I would like to do the same in VB.NET so that I can check if the boolean has
been explicitely defined (is not...
|
by: Chris |
last post by:
Hey all. Anyone who is familiar with Python programming knows that you
can have code like this:
list =
This code puts all the items processed by the for loop in a list plus
1. Is there a way...
|
by: dba123 |
last post by:
Why am I getting this error for Budget?
Error: An exception of type 'System.FormatException' occurred in
mscorlib.dll but was not handled in user code
Additional information: String was not...
|
by: vaibhav |
last post by:
Hi
I am writing a wrapper over the existing xalan libraries. I have to
pass xsl parameters to the xslt processor at run time. These paramters
are later referenced in the stylesheet .The xalan cpp...
|
by: =?Utf-8?B?ZGF2ZWJ5dGhlc2Vh?= |
last post by:
Hi folks,
Boolean.Parse("true") returns true, but what if you need to parse something
such as -
Boolean.Parse("(false && false) || (false || (true && true))");
Does something exist in the...
|
by: iain654 |
last post by:
I have finally worked out how to automatically send a range of cells in the body of an email using Outlook but it is very clumsy and I have to build up the email using the limit of line...
|
by: Jordan |
last post by:
Hi everyone,
I'm a big Python fan who used to be involved semi regularly in
comp.lang.python (lots of lurking, occasional posting) but kind of
trailed off a bit. I just wrote a frustration...
|
by: tshad |
last post by:
I have a value in my sql table set to tinyint (can't set to bit).
I am trying to move it into a boolean field in my program and have tried:
isTrue = (int)dbReader
and
isTrue =...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
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...
| |