嘿,
所以我正在编写我的程序并遇到问题,这个问题是如何设置一个复选框,在选中时值为1。 / p>
A首先被宣布:
Dim A1,A2,A3,A4,A5 As Integer
if语句:
如果cbQ1A1.Checked = True则为 A1 = cbQ1A1.Checked = 1 否则 A1 = 0 结束如果 如果cbQ2A1.Checked = True则为 A2 = cbQ2A1.Checked = 1 否则 A2 = 0 结束如果 如果cbQ3A1.Checked = True则为 A3 = cbQ3A1.Checked = 1 否则 A3 = 0 结束如果 如果cbQ4A1.Checked = True则为 A3 = cbQ3A1.Checked = 1 否则 A3 = 0 结束如果 如果cbQ5A1.Checked = True则为 A3 = cbQ3A1.Checked = 1 否则 A3 = 0 结束如果======================
那么我想要做什么然后将其全部添加:
总计= A1 + A2 + A3 + A4 + A5
========= ==============
之后我会有一个标签显示总数。
非常感谢您的帮助:)
解决方案
您好,
请添加到表格的第一行
选项严格开启
注意这将显示大量例外情况例如Checkbox的Checked属性不是整数,而是Boolean类型。您可以使用Checkbox控件的.Tag属性来存储数据,在需要时使用CInt(someCheckBox.Tag)来获取标记的值。
Hey,
So I am currently coding my program and have encountered a problem, this problem is how to set a checkbox to have a value of 1 when checked.
The A's are declared first:
Dim A1, A2, A3, A4, A5 As Integer
The if statements:
If cbQ1A1.Checked = True Then A1 = cbQ1A1.Checked = 1 Else A1 = 0 End If If cbQ2A1.Checked = True Then A2 = cbQ2A1.Checked = 1 Else A2 = 0 End If If cbQ3A1.Checked = True Then A3 = cbQ3A1.Checked = 1 Else A3 = 0 End If If cbQ4A1.Checked = True Then A3 = cbQ3A1.Checked = 1 Else A3 = 0 End If If cbQ5A1.Checked = True Then A3 = cbQ3A1.Checked = 1 Else A3 = 0 End If======================
So what I am trying to do with this is then add it all up:
Total = A1 + A2 + A3 + A4 + A5
=======================
After this I will then have a label which will display the total number.
Many thanks for the help in advance :)
解决方案Hello,
Please add to the first line of the form
Option Strict On
Note this will shows a ton of exceptions e.g. Checked property of a Checkbox is not an integer but of type Boolean. You could use .Tag property of the Checkbox controls to store data which when needed use CInt(someCheckBox.Tag) to get the tag's value.
更多推荐
给复选框值
发布评论