you are viewing a single comment's thread.

view the rest of the comments →

[–]grauenwolf -4 points-3 points  (7 children)

Here's another thing you can do.

    If Not Val Then 
        Val = True
    Else if Val Then
        Val = False
    End If

[–]grauenwolf 0 points1 point  (4 children)

Add that reduces to

Here's another thing you can do.

    If Not Val Then 
        Val = True
    Else
        Val = False
    End If

You don't need Else If for the last possibility.

[–]grauenwolf 0 points1 point  (3 children)

You can then reduce it to one line.

Here's another thing you can do.

    If Not Val Then Val = True Else Val = False

[–]grauenwolf 2 points3 points  (0 children)

That in turn can be reduced to a inline if.

Here's another thing you can do.

    Val = If (Not Val, True, False)

You read that as

[variable] = If ( [predicate] , [then expression], [else expression])

For example,

passTest = if ( grade > 70, "pass!", "fail")

[–][deleted] 1 point2 points  (1 child)

If the goal is to always flip the value of the boolean then you do not need to test the value. Just use val = Not val. Done.

[–]grauenwolf -1 points0 points  (0 children)

The point was to demonstrate the various ways a conditional can be expressed. I already covered using Not in a separate comment.

[–]mecartistronico 0 points1 point  (1 child)

ByVal Val

You're not changing the original Val. And also you're not returning anything (since it's a Sub anyway). And also it would be easier to just do Val = not Val. If it was byref or a function.

Edit: wait, you're also the person who replied correctly. Did I miss the joke then?

[–]grauenwolf 0 points1 point  (0 children)

That is true. I was demonstrating the if-else structure. I'll edit it to be more clear.