If CheckBox1.Checked Then
Dim toi = "Toilets"
CheckBox1.Text = toi
TextBox7.Text = toi.ToString
End If
If CheckBox2.Checked Then
Dim park = "Parking"
CheckBox2.Text = park
End If
If CheckBox3.Checked Then
Dim decore = "Decore"
CheckBox3.Text = decore
End If
If CheckBox4.Checked Then
Dim food = "Catering"
CheckBox4.Text = food
End If
If CheckBox5.Checked Then
Dim cool = "Air Conditioning"
CheckBox5.Text = cool
End If
Checkedbox value to be saved as a variable
Page 1 of 15 Replies - 210 Views - Last Post: 10 October 2012 - 07:00 AM
#1
Checkedbox value to be saved as a variable
Posted 09 October 2012 - 03:28 PM
I understand that the declaration is within the if...then tags but how can I make sure that when the checkedbox is checked and assign it a variable to use in the later on in my code? Totally stumped. This is what I have managed to pull out of my grey matter. lol.
Replies To: Checkedbox value to be saved as a variable
#2
Re: Checkedbox value to be saved as a variable
Posted 09 October 2012 - 06:00 PM
What's the data type of a the checkbox's "checked" property? Boolean! Store it in one of those!
#3
Re: Checkedbox value to be saved as a variable
Posted 09 October 2012 - 10:22 PM
I am assuming they are boolean. But where I am struggling is, to assign a variable example:
!!!NOTE THIS IS NOT CODE BUT SIMPLY A WAY FOR ME TO EXPLAIN BETTER!!!!
DIM var as string
where if checkbox1.checked then save the value to var
and if not checked then do nothing.
code...code...
display var to label1
end sub
I just need the user of the program to know which of the checkboxs was checked. I need to save to a database and display later in the program
I hope you understand what I am trying to say
!!!NOTE THIS IS NOT CODE BUT SIMPLY A WAY FOR ME TO EXPLAIN BETTER!!!!
DIM var as string
where if checkbox1.checked then save the value to var
and if not checked then do nothing.
code...code...
display var to label1
end sub
I just need the user of the program to know which of the checkboxs was checked. I need to save to a database and display later in the program
I hope you understand what I am trying to say
This post has been edited by wanabavbcoder: 09 October 2012 - 10:25 PM
#4
Re: Checkedbox value to be saved as a variable
Posted 09 October 2012 - 11:19 PM
Having the values stored in a variable is one thing - making the connection to a database is another.
There are DB tutorials in the VB.NET tutorial section if you want to do the latter.
dim bVal as boolean = false bVal = checkbox1.checked
There are DB tutorials in the VB.NET tutorial section if you want to do the latter.
#5
Re: Checkedbox value to be saved as a variable
Posted 10 October 2012 - 12:14 AM
okay that is awesome.
NO ERRORS!
so now how would my program know that when the box is checked that it must save bVal as Toilets.
My goal is to assign 5 variables for 5 checkboxes.
when the checkboxes is checked then i need to display the values of the all the checkboxes that are checked in a label and leave out the ones that are unchecked.
The database part is covered. But thanks for the tip. I will have a go at it.
Dim bVal As boolean = False
bVal = CheckBox1.Checked
NO ERRORS!
so now how would my program know that when the box is checked that it must save bVal as Toilets.
My goal is to assign 5 variables for 5 checkboxes.
when the checkboxes is checked then i need to display the values of the all the checkboxes that are checked in a label and leave out the ones that are unchecked.
The database part is covered. But thanks for the tip. I will have a go at it.
#6
Re: Checkedbox value to be saved as a variable
Posted 10 October 2012 - 07:00 AM
Quote
so now how would my program know that when the box is checked that it must save bVal as Toilets.
Check the events man! Each checkbox has a 'check changed' event. Set it up an inside each set a boolean variable to the value of the checkbox.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote






|