reverse boolean?

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Is it possible in B4P to reverse a boolean as you can do in VB, eg:
txtTest.Visible = (bBool = False)

It would be useful as you could then reduce the code in procedures like this:

Sub ShowHidePaymentList(bShow)

If bShow = True Then
btnNewPayment.Visible = False
btnDeletePayment.Visible = False
btnClearAllP.Visible = False
btnPractices.Visible = False
btnPaymentsList.Visible = False
tblPayments.Visible = True
Else
tblPayments.Visible = False
btnNewPayment.Visible = True
btnDeletePayment.Visible = True
btnClearAllP.Visible = True
btnPractices.Visible = True
btnPaymentsList.Visible = True
End If

End Sub


RBS
 

Byak@

Active Member
Licensed User
Yes

btnNewPayment.Visible = not(btnNewPayment.Visible)
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Yes, I knew that one, but it is not quite the same as reversing a "Boolean" variable. How would you code the posted procedure without the If Else
construction?

RBS
 

specci48

Well-Known Member
Licensed User
Longtime User
Hi RB Smissaert,

I would code it like that:
B4X:
Sub ShowHidePaymentList(bShow)
   tblPayments.Visible = bShow
   btnNewPayment.Visible = Not(bShow)
   btnDeletePayment.Visible = Not(bShow)
   btnClearAllP.Visible = Not(bShow)
   btnPractices.Visible = Not(bShow)
   btnPaymentsList.Visible = Not(bShow)
End Sub


specci48
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Thanks, I am nearly sure I tried that and for some reason it didn't work, but will try again tonight.

RBS
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Yes, that works fine.
I think I had done Not bShow as in VB.
Thanks again for clearing that up.

RBS
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…