<p>Is there ever a circumstance in which I would not want to use the <a href="http://msdn.microsoft.com/en-us/library/cb8x3kfz.aspx" rel="noreferrer"><code>AndAlso</code></a> operator rather than the <a href="http://msdn.microsoft.com/en-us/library/sdbcfyzh.aspx" rel="noreferrer"><code>And</code></a> operator?  &hellip;or in which I would not want to use the <a href="http://msdn.microsoft.com/en-us/library/ea1sssb2.aspx" rel="noreferrer"><code>OrElse</code></a> operator rather than the <a href="http://msdn.microsoft.com/en-us/library/06s37a7f.aspx" rel="noreferrer"><code>Or</code></a> operator?</p>

[{'answer_id': 55025, 'author': 'Joel Coehoorn', 'author_id': 3043, 'author_profile': 'https://Stackoverflow.com/users/3043', 'pm_score': 4, 'selected': False, 'text': '<blockquote>\n  <p>Is there ever a circumstance in which I would not want to use the AndAlso operator rather than the And operator?</p>\n</blockquote>\n\n<p>Sure: if you want to make sure that <em>both</em> sides of the expression are evaluated.  This might be the case if, for example, both sides are method calls that return booleans as a result of some other operation that has a side effect.</p>\n\n<p>But in general, use <code>AndAlso</code>/<code>OrElse</code> whenever you would use <code>&amp;&amp;</code>/<code>||</code> in C/C++/C#, which of course is the vast majority of the time.</p>\n'}, {'answer_id': 55031, 'author': 'Vaibhav', 'author_id': 380, 'author_profile': 'https://Stackoverflow.com/users/380', 'pm_score': 6, 'selected': True, 'text': '<p>From <a href="http://msdn.microsoft.com/en-us/library/wz3k228a.aspx" rel="noreferrer">MSDN</a>:</p>\n\n<p><strong>Short-Circuiting Trade-Offs</strong></p>\n\n<p><em>Short-circuiting can improve performance by not evaluating an expression that cannot alter the result of the logical operation. However, if that expression performs additional actions, short-circuiting skips those actions. For example, if the expression includes a call to a Function procedure, that procedure is not called if the expression is short-circuited, and any additional code contained in the Function does not run. If your program logic depends on any of that additional code, you should probably avoid short-circuiting operators.</em> </p>\n'}, {'answer_id': 69841478, 'author': 'Andrew', 'author_id': 6794075, 'author_profile': 'https://Stackoverflow.com/users/6794075', 'pm_score': 0, 'selected': False, 'text': "<p>They are completely different functionalities in VB.net and both have their use cases (though for the most common use both will work)</p>\n<p><code>AndAlso</code> and <code>OrElse</code> are <strong>conditional</strong> operators, they return a true or false boolean value and only evaluate what they need to until they reach the result that cannot be altered (false for AndAlso, true for OrElse). These are the equivalent of <code>&amp;&amp;</code> and <code>||</code> in languages like C# and Java.</p>\n<p><code>And</code> and <code>Or</code> are <strong>bitwise</strong> operators, they combine the bits of whatever is passed to them into a result, and since those bits can always be altered by further evaluation, need to evaluate everything. These are the equivalent of <code>&amp;</code> and <code>|</code> in languages like C# and Java.</p>\n<p>Most of the time, when you're looking at an and/or operation, you want conditional results. Bitwise operations will produce a value that is truthy or falsey and will (usually) match the true or false results from proper conditional operators, they will just take a bit longer on average since they evaluate everything.</p>\n<p>Bitwise operators are meant to be used when you care about the specific bits in a value, often used for storing settings or permissions in as compact a way as possible, and for reading and applying them as fast as possible. For example the read/write/execute permissions on files in Unix based systems use bit flags this way:</p>\n<blockquote>\n<p>0b001 - execute permission<br />\n0b010 - write permission<br />\n0b100 - read permission</p>\n</blockquote>\n<p>so, in decimal, a value of 7 can do all three, a value of 4 can only read, 6 can read and write, etc. If someone is trying to write to a file it checks their permissions by using <code>And 0b010</code> and gets a truthy or falsy result based on the bit in that position. To update the value to let users execute a file, you would use <code>Or 0b001</code> on their current permissions and store the result.</p>\n<p>The difference comes here:</p>\n<blockquote>\n<p>0b001 (truthy) And 0b010 (truthy) = 0b000 (falsy) <br />\n0b001 (truthy) AndAlso 0b010 (truthy) = True</p>\n</blockquote>\n"}]
['https://Stackoverflow.com/questions/55013', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/83/']