Solved

neat way of saying not(boolean)

Posted on 2003-12-01
2
233 Views
Last Modified: 2011-09-20
I am using VB6:

My code is as follows:
                    dim tEnabled as boolean
                    If .Enabled = "EnableIfElectronic" Then
                        tEnabled = isElectronic
                    ElseIf .Enabled = "DisableIfElectronic" Then
                        tEnabled = not(isElectronic)  'note the 'not() in this line is obviously only my wishful thinking.
                    End If


I know I could write a quickfunction, or just add any extra 'if statement' ie:
                    dim tEnabled as boolean
                    If .Enabled = "EnableIfElectronic" Then
                        tEnabled = isElectronic
                    ElseIf .Enabled = "DisableIfElectronic" Then
                         if isElectronic then    
                                 tEnabled = false
                         else
                                 tEnabled = true
                        endif
                    End If


Just wondering if their is a neater way of doing this, such as a not() type function??

Thanks,
Cassandra
0
Comment
Question by:calebS
2 Comments
 
LVL 11

Accepted Solution

by:
dbrckovi earned 30 total points
ID: 9848778
Just remove brackets:

 tEnabled = Not isElectronic

Example:
Private Sub Command1_Click()
    Dim a As Boolean
    Dim b As Boolean
    a = True
    b = Not a
    Print a, b
End Sub
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 10167083
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered dbrckovi
 
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

leonstryker
EE Cleanup Volunteer
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA error replacing data 6 41
passing a value with stream reader AFTER a ";" 3 83
VBA Shell can't Find Word document 11 130
Zip Folders Using Chilkat Routines 1 74
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question