By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,168 Members | 2,599 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,168 IT Pros & Developers. It's quick & easy.

Comparing vs. Assigning

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
* "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

P: n/a
"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

P: n/a

"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.