[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

neat way of saying not(boolean)

Posted on 2003-12-01
2
Medium Priority
?
253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
dbrckovi earned 120 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 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