473,373 Members | 1,141 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,373 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 1243
* "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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Dimension7 | last post by:
All, I am comparing to functions to see which is "better". In better, I mean more efficient, optimize, faster, etc. I have read other posts from other boards, but I'm not really sure of the...
5
by: gtz669 | last post by:
I have a class which I am using for data stroage. I declare an instance of that class in my main class which is running my java applet. I Iassign it a value in the init () function and it works...
3
by: Zach | last post by:
What happens when you compare a char against an integer literal? For example, #include <iostream> using namespace std; int main(int argc, char* argv) { signed char c1 = 150; if (c1 < 150)...
14
by: Eric Bantock | last post by:
Very basic question I'm afraid. Once an array has been declared, is there a less tedious way of assigning values to its members than the following: myarray=8; myarray=3; myarray=4; myarray=0;...
4
by: - Steve - | last post by:
The following line of vb.net code works fine: if(strAnswer.toUpper() = strUserAnswer.toUpper()) However in an ASP.net page I'm told Object reference not set to an instance of an object ...
19
by: Dennis | last post by:
I have a public variable in a class of type color declared as follows: public mycolor as color = color.Empty I want to check to see if the user has specified a color like; if mycolor =...
1
by: Adrienne Boswell | last post by:
I have a form which I am letting the user enter more than one event at a time. I need to check whether one date is less than another. If the display to date is earlier than the event date, then...
2
by: Pugi! | last post by:
hi, I am using this code for checking wether a value (form input) is an integer and wether it is smaller than a given maximum and greater then a given minimum value: function...
5
by: SneakyElf | last post by:
I need to write a function where the third parameter points to an address whose dereferenced value equals one of the array element's value, then the the function returns the index of the first...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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 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.