checkbox question

magnuma1

Member
Licensed User
Longtime User
I am using checkbox and after checking the box I have a msgbox message displayed. then you click on the message display box which then goes away. How can I get the check box to be then unchecked, it's still checked?

Here is part of my code:

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub CheckBox1_CheckedChange(Checked As Boolean)
Msgbox("You Got It Baby!", "")
End Sub

Sub CheckBox2_CheckedChange(Checked As Boolean)
Msgbox("WRONG!", "")
End Sub

Sub CheckBox3_CheckedChange(Checked As Boolean)
Msgbox("WRONG!", "")
End Sub

Sub CheckBox4_CheckedChange(Checked As Boolean)
Msgbox("WRONG!", "")
End Sub
 

Jack Cole

Well-Known Member
Licensed User
Longtime User
You can probably do something like this:

B4X:
Sub CheckBox1_CheckedChange(Checked As Boolean)
   Msgbox("You Got It Baby!", "")
        CheckBox1.Checked=Not(CheckBox1.Checked)
End Sub

Or if you always want it to be unchecked:

B4X:
Checkbox1.Checked=False


I am using checkbox and after checking the box I have a msgbox message displayed. then you click on the message display box which then goes away. How can I get the check box to be then unchecked, it's still checked?

Here is part of my code:

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub CheckBox1_CheckedChange(Checked As Boolean)
Msgbox("You Got It Baby!", "")
End Sub

Sub CheckBox2_CheckedChange(Checked As Boolean)
Msgbox("WRONG!", "")
End Sub

Sub CheckBox3_CheckedChange(Checked As Boolean)
Msgbox("WRONG!", "")
End Sub

Sub CheckBox4_CheckedChange(Checked As Boolean)
Msgbox("WRONG!", "")
End Sub
 
Upvote 0

magnuma1

Member
Licensed User
Longtime User
I tried what you said and got this error:

Compiling code. Error
Error parsing program.
Error description: Undeclared variable 'checkbox1' is used before it was assigned any value.
Occurred on line: 28
Checkbox1.Checked=Not(CheckBox1.Checked)
 
Upvote 0

Jack Cole

Well-Known Member
Licensed User
Longtime User
In the Designer, you need to click on Tools, and Generate Members. Then click the checkbox next to all of your checkbox views. Then click generate members. Then run it again.

That provides the variable references in globals so that the view can be accessed from your code.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I'm wondering why you do use CheckBoxes just to show a MessageBox?
The principle of the CheckBoxes it to toggle between checked and unchecked, select something or unselect it.
As seemingly you don't need this function, why not using Buttons or Labels ?

Best regards.
 
Upvote 0

vb1992

Well-Known Member
Licensed User
Longtime User
Looks like a multiple choice question he is doing: (?)



What is a bird below:


[ ] Parakeet
[ ] Lion
[ ] Tiger
[ ] Bear


But you are right, he would have to uncheck it after he gets the msgbox
so it's not shown checked... or maybe he wants it checked to show
the user already tried that answer

or he could disable or make invisible after the msg box
 
Last edited:
Upvote 0

magnuma1

Member
Licensed User
Longtime User
You are correct. I am just learning all this programming stuff and it is fun. I just want to see what does what.

Thanks for all your input. I hope to remember it all.
 
Upvote 0
Top