0

I wonder in visual studio, what would be the code to acquire the value from the Checkbox. Say, if checked, value=1; if not, value=0. I know for radio button, I can automatically assign the value. But what about the checkbox? Do I even need to register a user control and write a case function such as

_checkResult = value

Select Case _checkResult
Case 1
     CheckBoxA.Checked = True                 
Case 0
     CheckBoxA.Checked = False

End Select

Much appreciated for any help:)

1 Answer 1

1

To get the value of a checkbox all you need to do is call Checked.

Your code is doing something different though. You are setting the value and a case statement correctly works to do this as long as value is restricted to being either 0 or 1. I would recommend to use a boolean datatype for _checkResult as this ensures that it will always be set. It also makes it easier to set the value as shown below.

CheckBoxA.Checked = _checkResult
Sign up to request clarification or add additional context in comments.

1 Comment

thanks very much for your advice! sorry that i was working on other part of codes.. I think your answer is right!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.