472,127 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Comparing vs. Assigning

How does VB.NET determine comparing vs. assigning?

For instance, if "checkbox1.checked = True" it only checks the value but
leaves it as it whereas if you have "checkbox1.checked = True" by itself it
changes the value. Is that correct? I believe in C you have a "=" and a "=
=",
one for assigning and one for comparing. Am I understanding VB.NET
correctly?
--
Thanks,
Ricky W. Hunt
freendeed

Nov 20 '05 #1
3 1176
* "Ricky W. Hunt" <rh*****@hotmail.com> scripsit:
How does VB.NET determine comparing vs. assigning?

For instance, if "checkbox1.checked = True" it only checks the value but
leaves it as it whereas if you have "checkbox1.checked = True" by itself it
changes the value. Is that correct? I believe in C you have a "=" and a "=
=",
one for assigning and one for comparing. Am I understanding VB.NET
correctly?


In VB.NET, the '=' operator is /overloaded/ for assinging and comparing,
depending on the situation. Notice that 'a = b = 1' will result in
differewnt results in VB.NET and C#. In VB.NET, the 2nd '=' compares
'b' with 1 and assigns the result ('True'/'False') to 'a'. In other
programming languages, 'b' is assigned 1, and 'a' get's 'b''s value, 1.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
<URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 20 '05 #2
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
* "Ricky W. Hunt" <rh*****@hotmail.com> scripsit:
How does VB.NET determine comparing vs. assigning?

For instance, if "checkbox1.checked = True" it only checks the value but
leaves it as it whereas if you have "checkbox1.checked = True" by itself it changes the value. Is that correct? I believe in C you have a "=" and a "= =",
one for assigning and one for comparing. Am I understanding VB.NET
correctly?


In VB.NET, the '=' operator is /overloaded/ for assinging and comparing,
depending on the situation. Notice that 'a = b = 1' will result in
differewnt results in VB.NET and C#. In VB.NET, the 2nd '=' compares
'b' with 1 and assigns the result ('True'/'False') to 'a'. In other
programming languages, 'b' is assigned 1, and 'a' get's 'b''s value, 1.


Wow. This explains so much but seems so dangerous. You would think this
stuff would be better documented.
Nov 20 '05 #3

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
* "Ricky W. Hunt" <rh*****@hotmail.com> scripsit:
How does VB.NET determine comparing vs. assigning?

<snip>
In VB.NET, the '=' operator is /overloaded/ for assinging and comparing,
depending on the situation. Notice that 'a = b = 1' will result in
differewnt results in VB.NET and C#. In VB.NET, the 2nd '=' compares
'b' with 1 and assigns the result ('True'/'False') to 'a'. In other
programming languages, 'b' is assigned 1, and 'a' get's 'b''s value, 1.


Ech... 'a=b=1' seems too messy to deal with anyway.
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Dimension7 | last post: by
5 posts views Thread by gtz669 | last post: by
3 posts views Thread by Zach | last post: by
14 posts views Thread by Eric Bantock | last post: by
4 posts views Thread by - Steve - | last post: by
19 posts views Thread by Dennis | last post: by
5 posts views Thread by SneakyElf | last post: by

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.