473,379 Members | 1,491 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Q: Converting CheckBox.Checked to an int?

Hi!

How do I convert a CheckBox.Checked to an int?

Regards

Martin Arvidsson
Jul 21 '05 #1
4 11099
VB.NET:

CType(checkbox.checked, Integer)
"Visual Systems AB (Martin Arvidsson)" <ma**************@vsab.net> wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi!

How do I convert a CheckBox.Checked to an int?

Regards

Martin Arvidsson

Jul 21 '05 #2
Hi Martin,

To get an int value out of you can do something like

int i = CheckBox.Checked ? 1 : 0;

A boolean value can't be translated to any other value, so you will need
to test it, if true use 1, otherwise use 0.

--
Happy Coding!
Morten Wennevik [C# MVP]
Jul 21 '05 #3
No, you shouldn't have to test it. You should be able to cast it into an
integer and get back 0 or 1 directly.
"Morten Wennevik" <Mo************@hotmail.com> wrote in message
news:opsghv7agoklbvpo@pbn_computer...
Hi Martin,

To get an int value out of you can do something like

int i = CheckBox.Checked ? 1 : 0;

A boolean value can't be translated to any other value, so you will need
to test it, if true use 1, otherwise use 0.

--
Happy Coding!
Morten Wennevik [C# MVP]

Jul 21 '05 #4
On Tue, 26 Oct 2004 17:25:53 -0400, Scott M. <s-***@nospam.nospam> wrote:
No, you shouldn't have to test it. You should be able to cast it into an
integer and get back 0 or 1 directly.


To add to this, there is no CType in C#, but you get the same effect using
Convert.ToInt32(bool)

--
Happy Coding!
Morten Wennevik [C# MVP]
Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John Mullen | last post by:
I want to take the following HTLM and use javascript to turn on radio buttons if checkbox is checked, can I do this with javascript (maybe onClick or an array) or do i need a server side script ?...
6
by: AFN | last post by:
I want to click a checkbox and have a 4 line (approx) paragraph appear beneath the checkbox, pushing the rest of the page down. And when unchecking the checkbox, the paragraph should disappear...
4
by: Kevin | last post by:
Hi, I have a input with type checkbox. I want it to be automatically checked if the value from the corresponding field in the database is also checked. I tried this: <% set objdc =...
4
by: RodBillett | last post by:
I have a situation where I have 3 checkboxes - and at least 1 needs to be selected at all times... I have implemented the code that allows this behavior to happen, BUT Viewstate gets all messed...
0
by: yurps | last post by:
Hello I have a DataList like this <asp:DataList id="Questions" Runat="server"> <ItemTemplate> <table border="1"> <tr> <td> <asp:CheckBox ID="Yes" Runat="server"></asp:CheckBox> <input...
2
by: Andrew | last post by:
Hi, I have a problem capturing the checkboxes that are checked, I get false irrespective of wether they are checked or not. I have gone thru the sample code on this forum, but they dun seem to...
4
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! How do I convert a CheckBox.Checked to an int? Regards Martin Arvidsson
3
by: nologo | last post by:
All, Have a problem i just cant find the answer for. I'm trying to populate a colum in a SQL database. Basically the column requires a 1 or 0. I'm trying to populate this col via a c#...
1
by: amel86 | last post by:
hello, i have a question. firstly sorry coz my grammar is not so good. i hope you all understand what question i will submit here.. the problem i face now is i cant retrieve all data that user...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.