M mistermentality Active Member Licensed User Longtime User Mar 13, 2011 #1 I have a check box that I need to tick or untick based on a users saved preferences read from a map but cannot seem to figure it out. I have tried Code: If Map1.Get("autosearch") = "True" Then CheckBox1_autosearchnet.Checked Where CheckBox1_autosearchnet is the check box name.Have tried other variations too such as Code: If Map1.Get("autosearch") = "True" Then CheckBox1_autosearchnet.Checked = True but without success. Unfortunately I am still new to B4A and never used a language that had check boxes before so can someone please tell me what I have done wrong? Thanks. Dave
I have a check box that I need to tick or untick based on a users saved preferences read from a map but cannot seem to figure it out. I have tried Code: If Map1.Get("autosearch") = "True" Then CheckBox1_autosearchnet.Checked Where CheckBox1_autosearchnet is the check box name.Have tried other variations too such as Code: If Map1.Get("autosearch") = "True" Then CheckBox1_autosearchnet.Checked = True but without success. Unfortunately I am still new to B4A and never used a language that had check boxes before so can someone please tell me what I have done wrong? Thanks. Dave
K kickaha Well-Known Member Licensed User Longtime User Mar 13, 2011 #2 I just added a checkbox called Checkbox1 to my test program, and put Code: Checkbox1.Checked = Not (Checkbox1.Checked) in a button_Click event and it worked just fine - everytime I clicked the button the checkbox changed state. There must be something else going on in your code - I would suspect that the Map1.Get("autosearch") is not returning the value you think it is. Do you get an error or does it just not work. Oh, and not to forget Code: Dim CheckBox1 As CheckBox in Globals. Last edited: Mar 13, 2011 Upvote 0
I just added a checkbox called Checkbox1 to my test program, and put Code: Checkbox1.Checked = Not (Checkbox1.Checked) in a button_Click event and it worked just fine - everytime I clicked the button the checkbox changed state. There must be something else going on in your code - I would suspect that the Map1.Get("autosearch") is not returning the value you think it is. Do you get an error or does it just not work. Oh, and not to forget Code: Dim CheckBox1 As CheckBox in Globals.
M mistermentality Active Member Licensed User Longtime User Mar 14, 2011 #3 kickaha said: There must be something else going on in your code - I would suspect that the Map1.Get("autosearch") is not returning the value you think it is. Click to expand... Thank you I don't know why but the variables stored are Booleans and so either True or False yet were stored in lower case. I was checking for "True" not "true". Changed it to save not the Boolean value but "enabled" or "disabled" and that turned out to be the problem. Dave Upvote 0
kickaha said: There must be something else going on in your code - I would suspect that the Map1.Get("autosearch") is not returning the value you think it is. Click to expand... Thank you I don't know why but the variables stored are Booleans and so either True or False yet were stored in lower case. I was checking for "True" not "true". Changed it to save not the Boolean value but "enabled" or "disabled" and that turned out to be the problem. Dave
agraham Expert Licensed User Longtime User Mar 14, 2011 #4 Don't check Booleans against String values, use the True and False keywords. Upvote 0