473,385 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

= operator overloaded in VB6 or VB.NET

One interesting observation I found is VB6 or VB.NET overloads = opeartor.
i.e. = operator has 2 meanings.

Case 1: relational operator. In other languages, usually use == instead.
If a = b Then statement

Case 2: assignment operator
a = b

Just my observation. Please discuss.
Nov 19 '05 #1
32 3862
Hello,

"John Davis" <jr*******@hotmail.com> schrieb:
One interesting observation I found is VB6 or
VB.NET overloads = opeartor.
i.e. = operator has 2 meanings.


That's right. It's one of the main reasons why I use VB Classic/VB
..NET.

Notice that an X-post to microsoft.public.vb.controls doesn't make any
sense.

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 19 '05 #2
huh??

"John Davis" <jr*******@hotmail.com> wrote in message
news:O0**************@tk2msftngp13.phx.gbl...
One interesting observation I found is VB6 or VB.NET overloads = opeartor.
i.e. = operator has 2 meanings.

Case 1: relational operator. In other languages, usually use == instead.
If a = b Then statement

Case 2: assignment operator
a = b

Just my observation. Please discuss.

Nov 19 '05 #3

"John Davis" <jr*******@hotmail.com> wrote in message
news:O0**************@tk2msftngp13.phx.gbl...
One interesting observation I found is VB6 or VB.NET overloads = opeartor.
i.e. = operator has 2 meanings.


For reference, from the very beginnings of BASIC the = operator has
performed double-duty, although in the Bad Old Days, the Let statement was
required (ick!) for assignments. Fortunately that went away quickly.

(Not that this has anything to do with controls, but I WILL admit that it IS
relevant to both .NET and non-.NET groups, a rarity there....)
Nov 19 '05 #4
steve wrote:
On Tue, 15 Jul 2003 18:08:42 -0700, "John Davis"
<jr*******@hotmail.com> wrote:

One interesting observation I found is VB6 or VB.NET overloads = opeartor.
i.e. = operator has 2 meanings.

Case 1: relational operator. In other languages, usually use == instead.
If a = b Then statement

Case 2: assignment operator
a = b

Just my observation. Please discuss.
vb is pretty cool huh! == has always wound me up, leads to annoying
errors that don't show up when compiling and are often difficult to
track down when debugging. Its like the f puzzle. The brain doesn't
automatically distinguish == from = when looking at code because we
are used to just = in everyday life.


Not relavent in Java/C#. Compiler catches this because expressions in
if statements must evaluate to a boolean :)

Tom Shelton
But is this relevant in non dotnet groups?


Nov 19 '05 #5
a = b is short for Let a = b

If a = b is just what it implies - if a.equals(b) = true

The operator can do double duty because its use is non-ambiguous in either
situation. In other cases, + could be ambiguous, so the string concat
operator & was added to provide a non-ambiguous addition method for adding
strings together.

-- russ

"John Davis" <jr*******@hotmail.com> wrote in message
news:O0**************@tk2msftngp13.phx.gbl...
One interesting observation I found is VB6 or VB.NET overloads = opeartor.
i.e. = operator has 2 meanings.

Case 1: relational operator. In other languages, usually use == instead.
If a = b Then statement

Case 2: assignment operator
a = b

Just my observation. Please discuss.

Nov 19 '05 #6
On Tue, 15 Jul 2003 23:29:37 -0400, "Jeff Johnson [MVP: VB]"
<pa******@com.geocities> wrote:

"John Davis" <jr*******@hotmail.com> wrote in message
news:O0**************@tk2msftngp13.phx.gbl...
One interesting observation I found is VB6 or VB.NET overloads = opeartor.
i.e. = operator has 2 meanings.


For reference, from the very beginnings of BASIC the = operator has
performed double-duty, although in the Bad Old Days, the Let statement was
required (ick!) for assignments. Fortunately that went away quickly.

(Not that this has anything to do with controls, but I WILL admit that it IS
relevant to both .NET and non-.NET groups, a rarity there....)


but probably not vb groups. Most vb developers would probably think
overloading meant pushing a program to hard <g>

Nov 19 '05 #7
Cor
John,
I don't know how many natural languages you speak, but for people who are
familiar with more languages, it is normal that in every language one word
can have more than one meaning.

The place of the word in the full sentence makes is very easy for the human
brain to understand the meaning for the meaning of the word. So that is
possible with the computer too.

Therefore I never understand why they made the ==, &&, || operators.

The "If" word says everything over the meaning and you can use the () if
there is a real problem.

I think the == and things like that are designed by mathematica people with
a very small knowledge natural languages.
A computer language is not anymore only a string of formules.
For that there was Algol and Fortran (And to say that that where languages
is the same as saying HTML and XML are languages).

What I don't understand is why the "then" is still necessary in VB.
But maybe is that for what Herfried says, "VB is so nice readable".

Cor

Nov 19 '05 #8
I suspect this is an inheritance from VB's humble beginnings.

As others have already pointed out in this thread, VB also overloads the
And, Or, Xor, and Not operators. They can each be used in a "bitwise"
context, e.g.
x = y And z
or a "logical" context, e.g.
If x<0 Or Y<0 Then

The reason is related to the overloading of the '=' operator. Very simple
languages (as Basic was), especially those that are interpreted, reduce
their complexity by handling conditional expressions using exactly the same
expression analyser as arithmetic expressions, and using a stack-based
evaluator for both [Huh?].

For instance, the above 'If' statement might be evaluated as follows:
push x ' push x on evaluation stack
push 0 ' push 0
test_lt ' compare top 2 elements, and replace by a boolean
push y
push 0
test_lt
or ' combine top 2 elements using bitwise 'Or'

Note that the evaluation uses only bitwise operations. The compiler (or
interpreter) doesn't need to worry about coding jumps, or short-circuiting
evaluation.

This is also the reason why 'True' in VB has the value -1, and not 1 as in
C/C++. Otherwise, the following would not be correct:
False = Not True

Tony Proctor

"John Davis" <jr*******@hotmail.com> wrote in message
news:O0**************@tk2msftngp13.phx.gbl...
One interesting observation I found is VB6 or VB.NET overloads = opeartor.
i.e. = operator has 2 meanings.

Case 1: relational operator. In other languages, usually use == instead.
If a = b Then statement

Case 2: assignment operator
a = b

Just my observation. Please discuss.

Nov 19 '05 #9
Cor
Hello Rainer,
I do not agree with you.

You speak more than one language. So that is not discussable. But lets bring
it back to natural language.

When you say: a is b you means a is equal to b.
Sometimes you mean a is the sum of a and b.
That is natural language.
I did not know that the sentence a=b=3 exist in VB and I agree that when it
is there it should give back a 1 and not an integer result of False or True

You speak German (me too but I cannot write it) and you know that you have
some words that don't exist in English. We can communicate in that
language.

An == operator is not necassery and I hate it in JavaScript that I often
use.
In VB you say.
If b=1 then
a = 1
b = a
end if
It is a nice sentence and you have to be very stupid not to understand it.

Of course we mis for years a=b=c=d and c++ --c but that will change in
future I supose.

When there would be an operator in this sentence I would choise for
a=b?b=c then we should use normal European 2500 years old characters quick
to understand to everybody that knows those characters.

Cor
Nov 19 '05 #10
Cor
Tony,
Just a discussion and I don't known if it is often been, but I like the
topic.

When I started there was Basic Assembler and we had the same instructions
you use.
(I think yours are for the Intel 8086 serie because every processor has his
own).
The Or, And and Xor where very much used, because the register (not the
registry) was very small, just 8 bits and you had to add the overflow bit to
another register.
Computers where growing and we got registers in a size from about 1K.
There was no need more to use those time spending instructions........ till
the micro processor came and it started all over again..

With the big registers we had Algol, Fortran and Cobol.
Algol and Fortran where the winners in the beginning because all people did
programming in the 8 bit way.
It was based on mathametic code.
Cobol still exist and it was the winner for a long time..
It says COmmon Businness Oriented Language.
It true is a language, very good readable when well used, but programming
now is not only done for business.
And in my opinion it is not usable anymore for about 15 years.

Programs have to be readable to survive, therefore they have to be readable.
But all expirenced programmers know that, only the beginners still have to
learn.
Cor

Nov 19 '05 #11
> I did not know that the sentence a=b=3 exist in VB and I agree that when
it
is there it should give back a 1 and not an integer result of False or True

Why should it give a one? A = B = 3 is "A becomes equal to the comparison of
(B = 3)". B = 3, in this instance, results in a boolean expression.

True is usually -1, because Booleans are usually signed and true is All Bits
On (using two's complement we end up with -1). All bits off, obviously, is
0. => False.

--
Happy to help,
-- Tom Spink
(th**********@ntlworld.com)

"Go down with your server"

http://dotnetx.betasafe.com >> On The Mend

Please respond to the newsgroup,
so all can benefit
"Cor" <no*@non.com> wrote in message news:bf**********@reader11.wxs.nl... Hello Rainer,
I do not agree with you.

You speak more than one language. So that is not discussable. But lets bring it back to natural language.

When you say: a is b you means a is equal to b.
Sometimes you mean a is the sum of a and b.
That is natural language.
I did not know that the sentence a=b=3 exist in VB and I agree that when it is there it should give back a 1 and not an integer result of False or True
You speak German (me too but I cannot write it) and you know that you have some words that don't exist in English. We can communicate in that
language.

An == operator is not necassery and I hate it in JavaScript that I often
use.
In VB you say.
If b=1 then
a = 1
b = a
end if
It is a nice sentence and you have to be very stupid not to understand it.

Of course we mis for years a=b=c=d and c++ --c but that will change in
future I supose.

When there would be an operator in this sentence I would choise for
a=b?b=c then we should use normal European 2500 years old characters quick to understand to everybody that knows those characters.

Cor

Nov 19 '05 #12
That's precisely the point Charles: That sort of approach doesn't
distinguish conditional expressions from arithmetic ones, or boolean values
from integer types. The x=y And z can be blindly evaluated using only
bitwise operations.

Tony

"Charles Law" <la****@btinternet.com> wrote in message
news:eP**************@tk2msftngp13.phx.gbl...
Hi Tony

It is interesting that you picked on the example

x = y And z

as this could also have the meaning (if it were allowed)

x = True, if y is True and z is True, otherwise x = False

which is a logical interpretation rather than a bitwise one.

Also, I wasn't clear whether you thought that True should be -1 (VB) or 1
(C/C++).

I would suggest that there is no justification for True to be defined as 1. It should always be -1 since the definition of True is

True = Not False

where False is always defined as zero. Thus, by Not-ting 0, i.e. changing
all 1s to 0s and 0s to 1s, we get FFFFFFFF, or -1 in as many bits as we care to store the value.

Regards

Charles
"Tony Proctor" <tony_proctor@aimtechnology_NOSPAM.com> wrote in message
news:u9**************@tk2msftngp13.phx.gbl...
I suspect this is an inheritance from VB's humble beginnings.

As others have already pointed out in this thread, VB also overloads the
And, Or, Xor, and Not operators. They can each be used in a "bitwise"
context, e.g.
x = y And z
or a "logical" context, e.g.
If x<0 Or Y<0 Then

The reason is related to the overloading of the '=' operator. Very simple
languages (as Basic was), especially those that are interpreted, reduce
their complexity by handling conditional expressions using exactly the

same
expression analyser as arithmetic expressions, and using a stack-based
evaluator for both [Huh?].

For instance, the above 'If' statement might be evaluated as follows:
push x ' push x on evaluation stack
push 0 ' push 0
test_lt ' compare top 2 elements, and replace by a boolean
push y
push 0
test_lt
or ' combine top 2 elements using bitwise 'Or'

Note that the evaluation uses only bitwise operations. The compiler (or
interpreter) doesn't need to worry about coding jumps, or short-circuiting evaluation.

This is also the reason why 'True' in VB has the value -1, and not 1 as in C/C++. Otherwise, the following would not be correct:
False = Not True

Tony Proctor

"John Davis" <jr*******@hotmail.com> wrote in message
news:O0**************@tk2msftngp13.phx.gbl...
One interesting observation I found is VB6 or VB.NET overloads =

opeartor. i.e. = operator has 2 meanings.

Case 1: relational operator. In other languages, usually use == instead. If a = b Then statement

Case 2: assignment operator
a = b

Just my observation. Please discuss.



Nov 19 '05 #13
"steve" <no****@here.co> wrote in message
news:ac********************************@4ax.com...
On Tue, 15 Jul 2003 23:29:37 -0400, "Jeff Johnson [MVP: VB]"
<pa******@com.geocities> wrote:

"John Davis" <jr*******@hotmail.com> wrote in message
news:O0**************@tk2msftngp13.phx.gbl...
One interesting observation I found is VB6 or VB.NET overloads = opeartor.
i.e. = operator has 2 meanings.


For reference, from the very beginnings of BASIC the = operator has
performed double-duty, although in the Bad Old Days, the Let statement was
required (ick!) for assignments. Fortunately that went away quickly.

(Not that this has anything to do with controls, but I WILL admit that it IS
relevant to both .NET and non-.NET groups, a rarity there....)


but probably not vb groups. Most vb developers would probably think
overloading meant pushing a program to hard <g>


hyuck hyuck... that was a belly roller there steve... I see John was able to spot the
obvious very quickly as well. Now if y'all could just keep this thread in relevant groups,
us VB Classic idiots would be much obliged.
--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep it in the groups..
Nov 19 '05 #14
On Wed, 16 Jul 2003 07:39:49 -0700, "Ken Halter"
<Ken_Halter@Use_Sparingly_Hotmail.com> wrote:
"steve" <no****@here.co> wrote in message
news:ac********************************@4ax.com.. .
On Tue, 15 Jul 2003 23:29:37 -0400, "Jeff Johnson [MVP: VB]"
<pa******@com.geocities> wrote:
>
>"John Davis" <jr*******@hotmail.com> wrote in message
>news:O0**************@tk2msftngp13.phx.gbl...
>
>> One interesting observation I found is VB6 or VB.NET overloads = opeartor.
>> i.e. = operator has 2 meanings.
>
>For reference, from the very beginnings of BASIC the = operator has
>performed double-duty, although in the Bad Old Days, the Let statement was
>required (ick!) for assignments. Fortunately that went away quickly.
>
>(Not that this has anything to do with controls, but I WILL admit that it IS
>relevant to both .NET and non-.NET groups, a rarity there....)
>


but probably not vb groups. Most vb developers would probably think
overloading meant pushing a program to hard <g>


hyuck hyuck... that was a belly roller there steve... I see John was able to spot the
obvious very quickly as well. Now if y'all could just keep this thread in relevant groups,
us VB Classic idiots would be much obliged.

Sorry Ken, pretty lame attempt at humour I know but it sounded funny
to me at the time due to sleep deprivation.

:)
Nov 19 '05 #15
Cor
Tom,
I wrote somewhere else I am good in JavaScript, therefore I know that
instruction very well (and use it altough I always think it is not good
describing).
That instructions looks if it comes from visicalc, multiplan or lotus or
something.
The ones who made that where very inventieve but making program sentences
like those was not important in those days, nobody did use them.

I wish we had a natural language independent program language, so the
americans (and more counrtries including mine) would not have such an easy
way ahead at the rest of the world. But I am and idialist.
When I wrote the expresion I was thinking on a not existing expresion like
"make a = b if b = c" and I thought it would me more natural to express it
as a=b?b=c.
But it is just an idea.

(It would be a hell of a job to make all classes language independent and I
would not know how)

Cor
Nov 19 '05 #16
Cor
Tony,
I am always triggered by people who said, this is from a beginner or
Americans who write "can you writ those in decent Englesh". (I never saw
this from English people, they know we are speaking Oxford English in our
country (and not the American Oxford)).

So you used the "beginners" word so I was triggered.

But I keep this in mind, programming language is not the real world.
Just inventions from guys like you and me.
I learned that it is a goal to use as much posible the natural language.

I really don't know what English is for people in other countries, maybe
Herfried can tell that, but it looks for me more dificult (of course not for
Herfried).

No hard fealing, just fun.

Cor
Nov 19 '05 #17
Hello,

"Cor" <no*@non.com> schrieb:
But I keep this in mind, programming language is not
the real world.
Just inventions from guys like you and me.
I learned that it is a goal to use as much posible the
natural language.
Although I am a native German speaker, I liked BASIC because of its
natural character. I always/often think in natural language and using a
programming language that allows me to directly type if my thoughts
increases my productivity. Decoding of source code is easier too if the
code is written in a pseudo-natural programming language (and not ASCII
art).
I really don't know what English is for people in other
countries, maybe Herfried can tell that, but it looks for
me more dificult (of course not for Herfried).


I am not sure if I understand what you mean, but from my point of view I
don't had/have problems in understanding source code because I am not a
native Engligh speaking person. I treat the keywords as abstract symbols
even if they have similarity to words of a natural language.

"Dim"
engl.: dimension
germ.: dimensionieren
"Stop"
engl.: stop
germ.: Stop, stoppen
"End"
engl.: end
germ.: Ende, beenden
"Function"
engl.: function
germ.: Funktion
"If...Then"
engl.: If...then...
germ.: Wenn..., dann...
....

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 19 '05 #18
I actually used the word "beginnings" Cor, not "beginners", and this is a
real UK-English word in the Oxford English dictionary. :-)

Tony

"Cor" <no*@non.com> wrote in message news:bf**********@reader08.wxs.nl...
Tony,
I am always triggered by people who said, this is from a beginner or
Americans who write "can you writ those in decent Englesh". (I never saw
this from English people, they know we are speaking Oxford English in our
country (and not the American Oxford)).

So you used the "beginners" word so I was triggered.

But I keep this in mind, programming language is not the real world.
Just inventions from guys like you and me.
I learned that it is a goal to use as much posible the natural language.

I really don't know what English is for people in other countries, maybe
Herfried can tell that, but it looks for me more dificult (of course not for Herfried).

No hard fealing, just fun.

Cor

Nov 19 '05 #19
Cor
Herfried,
I am Dutch, I think you did know that already.
You know we deal very easy with the English language because our language is
quiet simular with that language even more than German. But English, German
and Duch are languages from the North sea and quiet simular(for who did not
know that).

I find it strange that you wrote that program sentences are abstracts for
you and in the same way wrote they are natural. (I think it is abstract for
most German people, that is normal because German is the major language in
Europe, but not for you).

But we agree and I have to say that my discussion is strange.
We both like VB.net because it is so natural (I hated VB till there was
VB.net, I did find the not anymore usable Cobol the best till now), and on
the other hand I want a language independent program language.
Cor
Nov 19 '05 #20
Cor
Tony,
You are right, when you are here I give you a nice Heineken.
Cor
Nov 19 '05 #21
Hello,

"Cor" <no*@non.com> schrieb:
I am Dutch, I think you did know that already.
I didn't know that.

;-)
You know we deal very easy with the English language
because our language is quiet simular with that language
even more than German.
When learning English at school, it was sometimes really hard for me.
The teachers didn't show us the similarity of German and English.
Engligh words are often very similar to German dialects, so it's easy to
remember them.
But English, German and Duch are languages from the North
sea and quiet simular(for who did not know that).
I already knew it.

;-)
I find it strange that you wrote that program sentences
are abstracts for you and in the same way wrote they
are natural.
I knew you would "complain" about this sentence. As a German speakter I
do not have problems to understand the meaning of the words in the code.
Nevertheless, I think of the large number of people in the world who
speak languages that are not similar to the English language. These
people will have really big problems in understanding the basics of our
programming languages.
(I think it is abstract for most German people, that is
normal because German is the major language in
Europe, but not for you).
You are right. I think the keywords are not "typical" Engligh, they are
often short or abbreviations, that's why I didn't say that its natural
language for me. There are similarities, I like them, but its not a
natural language.

;-)))
But we agree and I have to say that my discussion is strange.
We both like VB.net because it is so natural (I hated VB till
there was VB.net, I did find the not anymore usable Cobol
the best till now), and on the other hand I want a language
independent program language.


I agree with you.

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 19 '05 #22
Hello,

"Cor" <no*@non.com> schrieb:
You are right, when you are here I give you a nice
Heineken.


LOL

Regards,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 19 '05 #23
"Tom Spink" <th**********@ntlworld.com> wrote in
news:#T**************@tk2msftngp13.phx.gbl:
True is usually -1, because Booleans are usually signed and true is
All Bits On (using two's complement we end up with -1). All bits off,
obviously, is 0. => False.


This may be true of the language, but in my opinion, it is poor coding
practice to use a boolean state and an integer value. The two should not
be mixed.

IMHO

Chris

--
If you don't like lunchmeat, please remove it from my e-mail address to
send me an e-mail
Nov 19 '05 #24
"Charles Law" <la****@btinternet.com> wrote in
news:eP**************@tk2msftngp13.phx.gbl:

I would suggest that there is no justification for True to be defined
as 1. It should always be -1 since the definition of True is


I would suggest that there is no justification for treating True or False
and integer values at all!

IMHO with Option Strict On, the following code should not compile (and I
haven't tested in VS to see if it does):

Dim a As Boolean = True
Dim b As Integer = 0
Dim y As Integer

y = a And b 'IMHO, this should generate an error.

IMHO, booleans and integers should not be type compatible.

There was a big argument when VB.Net was first released about whether True
should be 1 or -1. I say that True should be True and should have no
integer value at all. It makes no logical sense to me to convert a boolean
value to an integer.

Chris

--
If you don't like lunchmeat, please remove it from my e-mail address to
send me an e-mail
Nov 19 '05 #25

"Tom Spink" <th**********@ntlworld.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
I did not know that the sentence a=b=3 exist in VB and I agree that when it
is there it should give back a 1 and not an integer result of False or

True

Why should it give a one? A = B = 3 is "A becomes equal to the comparison

of (B = 3)". B = 3, in this instance, results in a boolean expression.

True is usually -1, because Booleans are usually signed and true is All Bits On (using two's complement we end up with -1). All bits off, obviously, is
0. => False.


First, I totally agree with the respondent Chris, that boolean values should
never be treated as integers... But beyond that - VB was the only language
I ever used that defined true = -1 and false = 0. Most languages define it
as true <> 0, false = 0. Of course most if you do an integer conversion
define the actual value of true as 1.

Tom Shelton
Nov 19 '05 #26
Cor
Herfried,
Last sentence on this topic.
We agree. We know.
I did some studie about North Sea languages.
Just one word about it for you, once we had one language, so it are not
German Dialects, but the "basic" language LOL. (Till the bible was wroten by
Luther)
Cor
Nov 19 '05 #27
I know you've seen this before but... This outlines why True = -1 (because it's Not 0..
which is different than <> 0)

Microsoft Basic Logical Expression Evaluation
http://www.mvps.org/vb/index2.html?tips/truth.htm

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep it in the groups..

"Tom Shelton" <ts****@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...

First, I totally agree with the respondent Chris, that boolean values should
never be treated as integers... But beyond that - VB was the only language
I ever used that defined true = -1 and false = 0. Most languages define it
as true <> 0, false = 0. Of course most if you do an integer conversion
define the actual value of true as 1.

Tom Shelton

Nov 19 '05 #28
Cor
Tom,
Wrong,
Primarly we did use bit + bit = 0 both bits are equal
bit + bit = 1, bits are not equal.

I agree that -1 is stupid, but it has nothing to do with VB, it is a
behaviour of the object and in all languages that uses window objects the
same.

But I do not have a better sollution.

Cor
Nov 19 '05 #29
> as true <> 0, false = 0.

And something defined as not equal to zero is not zero?

Hence, True = Not 0 => Not &H00, => &HFF => -1 (Signed)

--
Happy to help,
-- Tom Spink
(th**********@ntlworld.com)

"Go down with your server"

http://dotnetx.betasafe.com >> On The Mend

Please respond to the newsgroup,
so all can benefit
"Tom Shelton" <ts****@yahoo.com> wrote in message
news:#q**************@TK2MSFTNGP12.phx.gbl...

"Tom Spink" <th**********@ntlworld.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
I did not know that the sentence a=b=3 exist in VB and I agree that
when it
is there it should give back a 1 and not an integer result of False
or True

Why should it give a one? A = B = 3 is "A becomes equal to the comparison
of
(B = 3)". B = 3, in this instance, results in a boolean expression.

True is usually -1, because Booleans are usually signed and true is All Bits
On (using two's complement we end up with -1). All bits off, obviously,

is 0. => False.


First, I totally agree with the respondent Chris, that boolean values

should never be treated as integers... But beyond that - VB was the only language I ever used that defined true = -1 and false = 0. Most languages define it as true <> 0, false = 0. Of course most if you do an integer conversion
define the actual value of true as 1.

Tom Shelton

Nov 19 '05 #30
Hello Chris,

"Chris Dunaway" <dunawayc@_lunchmeat_sbcglobal.net> schrieb im Newsbeitrag
news:Xn*****************@207.46.248.16...
...
This may be true of the language, but in my opinion, it is poor coding
practice to use a boolean state and an integer value. The two should not
be mixed.


The expression b=3 is of type boolean in VB if you convert TRUE to integer
you will get a value
of -1. In the ancient Versions of Basic there was no boolean so a boolean
operator returned an integer (0 or -1).

since the type of a is not stated explicit it is good coding style according
to you if a is dimed as boolean.

Nov 19 '05 #31
Hello Tom,
"Tom Shelton" <ts****@yahoo.com> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP12.phx.gbl...

...
First, I totally agree with the respondent Chris, that boolean values should never be treated as integers... But beyond that - VB was the only language I ever used that defined true = -1 and false = 0. Most languages define it as true <> 0, false = 0. Of course most if you do an integer conversion
define the actual value of true as 1.

Thats true for C and it's relatives. Strong typed Languages define boolean
as either true or false and nothing else.

The reason for the -1 in Basic is that
1. like in C there is no boolean (in original Basic) the if expression tests
against <> 0
2. unlike C there is only one AND and one OR that is used for boolean
operations
and for bit masking operations. C has && and & for and.
Tom Shelton

Nov 19 '05 #32
Cor
Tony,
I did not deal in the discussion, till now but:
0 = False and not False = True.
This has always been in every language and every computer.
That is the basic of programming.

I don't know but I think that even -0 is True, but for me is that bullshit.
That discussion I had once, but I always have to cry when I think about such
a discussion.

Cor


Nov 19 '05 #33

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

Similar topics

8
by: Nitin Bhardwaj | last post by:
Thanx in advance for the response... I wanna enquire ( as it is asked many a times in Interviews that i face as an Engg PostGraduate ) about the overloading capability of the C++ Language. ...
30
by: | last post by:
I have not posted to comp.lang.c++ (or comp.lang.c++.moderated) before. In general when I have a C++ question I look for answers in "The C++ Programming Language, Third Edition" by Stroustrup....
20
by: Ioannis Vranos | last post by:
When we use the standard placement new operator provided in <new>, and not a definition of owr own, isn't a call to placement delete enough? Consider the code: #include <new>
2
by: wongjoekmeu | last post by:
Hello All, I have a question about a C++ listing that I don't understand from a book that I use to learn C++. In the listing a class String is declared and defined. The beginning look like this...
7
by: Genival Carvalho | last post by:
Hello friends... Inside my class how do to use explicit using Overloaded operator or use default ? Ex: Dim x as Integer = A + B ' Use default + operator Dim OV as integer = X + Z ' I will...
6
by: idikoko | last post by:
I need help overloafing the <,> operators! I wrote a very simple complex numbers class which basically treats a double as an imaginary number. I wrote the code to overload the >,< operators but...
2
by: B. Williams | last post by:
I have an assignment for school to Overload the operators << and >and I have written the code, but I have a problem with the insertion string function. I can't get it to recognize the second of...
5
by: richard.parker | last post by:
Hello, I need to overload operator new with affecting the system libraries. Has anyone done this? I've got 2 static libraries and application source code where the operator needs to be...
5
by: raylopez99 | last post by:
I need an example of a managed overloaded assignment operator for a reference class, so I can equate two classes A1 and A2, say called ARefClass, in this manner: A1=A2;. For some strange reason...
2
by: subramanian100in | last post by:
overloaded operator=() -------------------------------- overloaded assignment operator should be a non-static MEMBER function of a class. This ensures that the first operand is an lvalue. If...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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 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.