• 0

Set Boolean to opposite in VB


Question

I am fairly new to VB.Net so please bear with me.

I have a situation where a Sub turns things on or off depending on a boolean passed into it. I would like to pass the boolean and use it to set visible (and readonly) properties of controls.

Lets assume valueBoolean = True. Some I want turned on (*.visible = valueBoolean). But there are some in the same Sub that I want turned off (*.visible = THEOPPOSITEOFvalueBoolean). I wanted to use <> (*.visible <> valueBoolean), but that isn't allowed.

I created a simple function called switchBoolean that does this. It finds the value of valueBoolean and returns the opposite (*.visible = switchBoolean(valueBoolean)). This works fine, but is there another way to do this that doesn't need a function call?

Thanks for the help.

Link to comment
https://www.neowin.net/forum/topic/543740-set-boolean-to-opposite-in-vb/
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Thanks for the post, but in VB, <> is the closest to != in C++ that I can find. From what I can see, setting a boolean to <> does not set a TRUE to FALSE or vice-versa. Booleans must be True or False. It would make sense if it is TRUE, then != TRUE would be FALSE, but it doesn't work that way. Any other sugestions?

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Some help with this plz.
    • Yeah, this was a major miss by MS. Having no way (without 3rd party software or running commands) to see the system time in seconds is just dumb. I get that is uses more battery power, so that is way it was on the notification screen instead of the taskbar itself, that screen isn't up all that often.
    • I totally agree. I may not love Windows 11, but I agree (and often point out) that the anti-11 hype is way over blown. I kind of suspect that as people are forced off Windows 10 onto the (likely) Windows 11 25H2 we will hear a ton of people acting like Windows 11 is finally usable for the first time. Hey, if that is their opinion, fine, but I can't help but wonder if they would have had the same option had they been forced onto version 23H2 or 24H2.
    • I have often thought this as well!! Why make a menu when 80% of the time Uninstall is the only option, and the other 20% of the time Repair is the only other option? That UI has plenty of room for those to appear as buttons...which would be more touch friendly too, something MS claims to care about.
    • People might assume I am a Win11 fan/supporter because I frequently call out what I preserve to either be exaggerations or misinformation about Windows 11. I try not to ever take sides. Just because I disagree with a statement made, doesn't mean I agree with the opposition, or even disagree with the sentiment behind the person making the statement. I have on occasion gotten in disagreements with people making overly glossy statements about Windows 11 or Windows in general, just like I have (on other forums) gotten into political disagreements with people who are on my side (to the extent having a "side" is even a thing when it comes to complex issues). Like any human, I am far from perfect, but I try my best to not be dogmatic with my thoughts.
  • Recent Achievements

    • Apprentice
      Wireless wookie went up a rank
      Apprentice
    • Week One Done
      bukro earned a badge
      Week One Done
    • One Year In
      Wulle earned a badge
      One Year In
    • One Month Later
      Wulle earned a badge
      One Month Later
    • One Month Later
      Simmo3D earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      610
    2. 2
      ATLien_0
      283
    3. 3
      +FloatingFatMan
      179
    4. 4
      Michael Scrip
      151
    5. 5
      Steven P.
      112
  • Tell a friend

    Love Neowin? Tell a friend!