Re: Case Statement

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Yes, True can be 1 for things like SQL Server and in some other languages, but by the time you've assigned them to boolean values in VB/VBA, they're necessarily going to have been converted to -1.


Rob

Marshall Barton wrote:
Robert Morley wrote:

I like Rick's suggestion, though the conversion to string and then comparison of strings would probably slow it down significantly if it were in a very tight loop...probably not a problem unless it's something running hundreds of thousands of times, though.

Another common, albeit somewhat cryptic, method of doing it is as follows:

Select Case -blVal - 2 * buVal '- 4 * Next1 - 8 * Next2 - 16 * Next3, etc.
Case 0 'blVal = False, buVal = False
Case 1 'blVal = True, buVal = False
Case 2 'blVal = False, buVal = True
Case 3 'blVal = True, buVal = True
End Select


Exactly the approach I thought was too cryptic to be useful,
especially to someone that had to ask how :-)

I would also worry about the value of True being different
in various possible data sources.

.



Relevant Pages

  • Re: True inconsistency in Python
    ... Of course the point that those tests aren't any less redundant from the ... >treated as a Boolean expression. ... >other languages), and after some point it should dawn on the programmer ... explicit comparison altogether or comparing against false, ...
    (comp.lang.python)
  • Re: Error "SQL Server does not allow remote connections"
    ... The application could not connect to the sql server db. ... network is blocking the connection. ... SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 ... integratedSecurity, SqlConnection owningObject) +737554 ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Need help with SELECT statement.
    ... How do you cast these bits to Boolean? ... in various programming ... What are called the X3J languages ... This is not the same as using flags for program control (flag ...
    (microsoft.public.sqlserver.programming)
  • Re: OOs best feature survey results
    ... I would probably define a boolean "string" ... I LIKE dynamic languages. ...
    (comp.object)
  • Re: Sql 2005: SSIS - How to convert "N/Y" CHAR(1) to byte type column
    ... below) to represent boolean types. ... i.e. an expression that takes a charconstruction_weld column value from the flat file and converts it to a bit type that is compatible with the construction_weld column in the wl_well_casing_liner table. ... > Before we go further on the issue, I'd like to know which data type you> want to use in SQL server, do you use any tinyint? ... I'm totally unfamiliar the grammar of SSIS expressions> and I ...
    (microsoft.public.sqlserver.dts)