给复选框值

编程入门 行业动态 更新时间:2024-10-27 08:27:28
本文介绍了给复选框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嘿,

所以我正在编写我的程序并遇到问题,这个问题是如何设置一个复选框,在选中时值为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.

更多推荐

给复选框值

本文发布于:2023-11-06 16:03:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564155.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:复选框

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!