# Check Box Value in VBA

I am working on a VBA form in Excel 2011.  I have several check boxes on my form that I am trying to assign a value.  Thus if the box is true, I want it to be = to 1 so I can add it in my formula.  Here is the code I have on my calculate button at this point:

If chkPatientSafety.Value = True Then
chkPatientSafety.Value = "1"
Else
chkPatientSafety.Value = "0"
End If

txtTotal = Val(cboRegulatory) + Val(chkPatientSafety)

The Val(cboRegulatory) works perfect.  I set the value in a list in my lookup list in my code and it applies the values no problem.  But I have an issue somewhere with my chkPatientSafety not receiving a 1 or 0 for its value so it will properly add in my txtTotal formula.  What am I doing wrong on assigning my check boxes a value?  I was thinking true = 1 and false = 0 by default on a check box.  But when it runs I get true or false not numerical.  New at this form and any help would be appreciated.

Thanks!
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Hi,

pls try (True = -1 in vba )

If chkPatientSafety.Value = True Then
chkPatientSafety.Value = True
Else
chkPatientSafety.Value = False
End If
txtTotal = Val(cboRegulatory) + Abs(chkPatientSafety)
Regards
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

You can also do this:
txtTotal = Val(cboRegulatory) + IIF(chkPatientSafety.Value, 1, 0)
and eliminate the IF prior.
0
Commented:
I didnt notice the test was on itself
my solution then only
txtTotal = Val(cboRegulatory) + Abs(chkPatientSafety)
' or
txtTotal = Val(cboRegulatory) - chkPatientSafety
0
Author Commented:
That worked great.  Thank you things have changed a small bit from vb6 to the .net world.  Guess if you stay up to date it would make things a little easier. haha
0
Group Finance ManagerCommented:
Does this work

chkPatientSafety.Value = chkPatientSafety.Value
txtTotal = Val(cboRegulatory) + Abs(chkPatientSafety)
1
Author Commented:
Roy_Cox yes that is what I am doing in my formula and have the values pulling from my name list as a bound column of 2.  They work perfectly and calculate the form exactly as I expected.  Thanks for the help.
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.