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!
gwlanksAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Rgonzo1971Commented:
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)

Open in new window

Regards

Experts Exchange Solution brought to you by

Your issues matter to us.

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

Start your 7-day free trial
Shaun KlineLead Software EngineerCommented:
You can also do this:
txtTotal = Val(cboRegulatory) + IIF(chkPatientSafety.Value, 1, 0)

Open in new window

and eliminate the IF prior.
Rgonzo1971Commented:
I didnt notice the test was on itself
my solution then only
txtTotal = Val(cboRegulatory) + Abs(chkPatientSafety)
' or 
txtTotal = Val(cboRegulatory) - chkPatientSafety

Open in new window

Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

gwlanksAuthor 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
Roy CoxGroup Finance ManagerCommented:
Does this work

chkPatientSafety.Value = chkPatientSafety.Value
         txtTotal = Val(cboRegulatory) + Abs(chkPatientSafety)

Open in new window

gwlanksAuthor 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.
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.