Capturing checkbox activity
Posted
#1
(In Topic #1079)
Trainee
I have a checkbox named DCAllStats that I am trying to do something with when a user changes the status of the checkbox. Looking at the associated events, it looked like click was the proper event, so I wrote the following code as a test:
Code
Public Sub DCAllStats_Click()
If DCAllStats.Value == True Then
Message("True")
Endif
If DCAllStats.Value == False Then
Message("False")
Endif
EndOf course, clicking on the checkbox of DCAllStats doesn't trigger the Message. (In fact, clicking on the text doesn't work either) I wrote a separate bit of code to trigger when the form itself loads, and it works just fine. Any idea on what I'm doing wrong? One additional piece of information is that the checkbox is contained in a TabStrip if that makes any difference.
Thank you in advance!
Posted
Guru

In gambas 2 equal signs == is ONLY used for "case insensitive string comparisons"
/cat/stringop - Gambas Documentation
So a "case insensitive string comparison" of 2 boolean values will always be False
try it using only one = sign
Posted
Trainee
Posted
Guru

Thagn said
Thank you! Serves me right for assuming!
haha , what is it they say? to assume makes an ass of u and me
You're welcome
It's an easy mistake to make when you are used to another languages syntax.
I'd have a good read of the topics on this page Gambas wiki language overview Just to familiarize yourself of some differences in gambas to whatever you are used to.
We are always happy to help here too if you get stuck
Posted
Regular

If you want, for the sake of brevity, you can do :? that as well:Thagn said
Code
Public Sub DCAllStats_Click()
If DCAllStats.Value == True Then
Message("True")
Endif
If DCAllStats.Value == False Then
Message("False")
Endif
End
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
1 guest and 0 members have just viewed this.


