neat way of saying not(boolean)

Posted on 2003-12-01
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
                                 tEnabled = true
                    End If

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

Question by:calebS
LVL 11

Accepted Solution

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

 tEnabled = Not isElectronic

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

Expert Comment

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.


EE Cleanup Volunteer

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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
VB error "Type mismatch" 2 60
VBA open file from excel cell 4 44
Reading the Contents of a Directory In Access VBA 5 77
Set email body to html using vbscript 6 49
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

861 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