Results 1 to 4 of 4

Thread: Reversing Multiple Booleans

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2012
    Location
    Los Angeles, CA
    Posts
    29

    Reversing Multiple Booleans

    How can I reverse a whole array of Booleans? Is there a simple way of doing this?

    Thanks.

  2. #2
    Frenzied Member
    Join Date
    Feb 2008
    Location
    Texas
    Posts
    1,288

    Re: Reversing Multiple Booleans

    vb Code:
    1. for i as integer = 0 to myarray.length - 1
    2.  
    3. myarray(i) = Not myarray(i)
    4.  
    5. next

    Something like that should work and is fairly simple.

    Justin
    You down with OOP? Yeah you know me!
    MCAD and MCMICKEYMOUSE (vb.net)

    ----

    If it even kinda helps... rate it : )

    Edit a Multi-page .tif file and save.

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,415

    Re: Reversing Multiple Booleans

    try this:

    vb Code:
    1. yourBooleanArray = Array.ConvertAll(yourBooleanArray, Function(b) Not b)

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Reversing Multiple Booleans

    Quote Originally Posted by .paul. View Post
    try this:

    vb Code:
    1. yourBooleanArray = Array.ConvertAll(yourBooleanArray, Function(b) Not b)
    One important point to note is that this doesn't actually affect the original array object, but rather create a new array object and assign that to the original variable. Generally speaking, that's not going to be an issue but, if you have some other reference to the original array somewhere, that will not be affected.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width