Solved

neat way of saying not(boolean)

Posted on 2003-12-01
2
215 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now