473,654 Members | 3,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Comparing vs. Assigning

How does VB.NET determine comparing vs. assigning?

For instance, if "checkbox1.chec ked = True" it only checks the value but
leaves it as it whereas if you have "checkbox1.chec ked = 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 1260
* "Ricky W. Hunt" <rh*****@hotmai l.com> scripsit:
How does VB.NET determine comparing vs. assigning?

For instance, if "checkbox1.chec ked = True" it only checks the value but
leaves it as it whereas if you have "checkbox1.chec ked = 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******** ********@TK2MSF TNGP12.phx.gbl. ..
* "Ricky W. Hunt" <rh*****@hotmai l.com> scripsit:
How does VB.NET determine comparing vs. assigning?

For instance, if "checkbox1.chec ked = True" it only checks the value but
leaves it as it whereas if you have "checkbox1.chec ked = 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******** ********@TK2MSF TNGP12.phx.gbl. ..
* "Ricky W. Hunt" <rh*****@hotmai l.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
1959
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 benefits or if there is a speed increase with one vs. the other. FIRST VERSION function is_active($module) { global $prefix, $dbi;
5
6398
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 fine but when I try to do the same assignment later on, it restults in a NullPointerException and I can not figure this out. Could someone please help. Thanks. Here's the code: public class A extends java.applet.Applet
3
3461
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) cout << "Less than 150.\n"; else
14
74840
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; myarray=0; myarray=1; myarray=8;
4
1336
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 What am I doing wrong?
19
2643
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 = Color.Empty then..... or if mycolor is Color.Empty then .......
1
1659
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 of course that's an error. I am getting values like: areaevent_display_from: 09/29/2006, 09/209/2006 areaevent_display_to: 09/29/2006, 08/29/2006 I could say:
2
3379
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 checkInteger(&$value, $checks) { $err = ''; if (!is_numeric($value) || (floatval($value) != intval($value))) { $err .= 'Input must be an integer. ';
5
1880
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 matching array element. Otherwise -1 is returned. Here's what I have but I am going obviously wrong somewhere: #include <iostream> using namespace std; // This function compares values
0
8706
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8475
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8591
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5621
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2709
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1915
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1592
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.