处理多个复选框 [英] Processing Multiple Check Boxes

查看:100
本文介绍了处理多个复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑如何在

网页上处理多个复选框。


让我们说我有三个复选框:

cbox1

cbox2

cbox3


我能想到的唯一方法代码可能性如下:


如果cbox1.checked = true则

..........

结束如果


如果cbox2.checked = true那么

.......

结束如果


如果cbox3.checked = true那么

.......

结束如果


如果cbox1.checked = true且cbox2.checked = true则

.......

结束如果


如果cbox1.checked = true且cbox3.checked = true则

.......

结束如果


而且If / End IF会永远持续下去!


正如你所看到的,如果我有大约8个复选框,这样做可能会导致

到大量的编码。我确定有更好,更简单的方式,

对吗?我想过使用一个精选案例,但这不会好多了我不会想到。


该应用程序是一个运行的查询对于访问

数据库中的单个表。每个复选框代表他们可以选择的每个字段,以便在表格或其他样式报告中显示




TIA,

吉姆

I''m having dificulty figuring out how to process multiple check boxes on a
web form.

Let''s say I have three check boxes:
cbox1
cbox2
cbox3

The only way I can think of to code the possibilities is something like:

If cbox1.checked = true then
..........
End if

If cbox2.checked = true then
.......
End If

If cbox3.checked = true then
.......
End if

If cbox1.checked = true and cbox2.checked = true then
.......
end if

If cbox1.checked = true and cbox3.checked = true then
.......
end if

And the If/End IFs go on forever!

As you can see, if I have around 8 check boxes, doing it this way could lead
to tremendous amounts of coding. I''m sure there''s a better, easier way,
right? I thought of using a select case but that wouldn''t be much better I
don''t think.

The application is a query that runs against a single table in an access
database. Each check box represents each field they could chose from to show
up in a table or other style report.

TIA,
Jim

推荐答案

为什么不这样做:


dim c as integer = 0

如果cbox3.Checked = True则c = 1

如果cbox2.Checked = True则c + = 2

如果cbox1.Checked =真然后c + = 4


选择案例c

案例0''没有支票

案例1''cbox 3

案例2''cbox 2

案例3''cbox 2& 3

案例4''cbox 1

案例5''cbox 1& 3

案例6''cbox 1& 2

案例7''cbox 1,2,& 3

结束选择


是的,这是古老的...但我来自Applesoft Basic背景:)

吉姆在亚利桑那州 < TI ******* @ hotmail.com>在消息中写道

新闻:OW ************** @ TK2MSFTNGP10.phx.gbl ...
Why not do something like:

dim c as integer = 0
if cbox3.Checked = True then c = 1
if cbox2.Checked = True then c += 2
if cbox1.Checked = True then c+=4

Select Case c
Case 0 ''No checks
Case 1 ''cbox 3
Case 2 ''cbox 2
Case 3 ''cbox 2 & 3
Case 4 ''cbox 1
Case 5 ''cbox 1 & 3
Case 6 ''cbox 1 & 2
Case 7 ''cbox 1,2, & 3
End Select

Yeah, it''s archaic...but I come from an Applesoft Basic background :)

"Jim in Arizona" <ti*******@hotmail.com> wrote in message
news:OW**************@TK2MSFTNGP10.phx.gbl...
我有教师如何处理
网页上的多个复选框。

我们说我有三个复选框:
cbox1
cbox2 cbox3

我能想到编写可能性的唯一方法是:

如果cbox1.checked = true则
...... ......
结束如果

如果cbox2.checked = true那么
......
结束如果

如果是cbox3 .checked = true然后
......
结束如果

如果cbox1.checked = true而cbox2.checked = true那么
.... ..
结束如果

如果cbox1.checked = true而cbox3.checked = true那么
......
结束如果
<并且If / End IF会永远持续下去!

正如您所看到的,如果我有大约8个复选框,这样做可能会导致大量的编码。我确定有一种更好,更简单的方式,对吧?我想过使用一个精选的案例,但这并不是更好,我不会想到。

应用程序是一个查询,它针对访问中的单个表运行<数据库。每个复选框代表他们可以选择的每个字段,以显示在表格或其他样式报告中。

TIA,
Jim
I''m having dificulty figuring out how to process multiple check boxes on a
web form.

Let''s say I have three check boxes:
cbox1
cbox2
cbox3

The only way I can think of to code the possibilities is something like:

If cbox1.checked = true then
.........
End if

If cbox2.checked = true then
......
End If

If cbox3.checked = true then
......
End if

If cbox1.checked = true and cbox2.checked = true then
......
end if

If cbox1.checked = true and cbox3.checked = true then
......
end if

And the If/End IFs go on forever!

As you can see, if I have around 8 check boxes, doing it this way could
lead to tremendous amounts of coding. I''m sure there''s a better, easier
way, right? I thought of using a select case but that wouldn''t be much
better I don''t think.

The application is a query that runs against a single table in an access
database. Each check box represents each field they could chose from to
show up in a table or other style report.

TIA,
Jim



" Jim in Arizona" < ti ******* @ hotmail.com>'狂野的想法

于2005年7月19日星期二16:21:09 -0700发布,带有

关注水果:
"Jim in Arizona" <ti*******@hotmail.com>''s wild thoughts
were released on Tue, 19 Jul 2005 16:21:09 -0700 bearing the
following fruit:
我正在研究如何在
网页上处理多个复选框。

让我们我说我有三个复选框:
cbox1
cbox2
cbox3

我能想到编写可能性的唯一方法就是:

如果cbox1.checked = true则
.........
结束如果

如果cbox2.checked = true则
......
结束如果

如果cbox3.checked = true那么
......
结束如果
......
结束如果

如果cbox1.checked = true且cbox3.checked =真如果
......
结束如果

并且If / End IF会永远持续下去!

如您所见,如果我有大约8个复选框,这样做可以导致大量的编码。我确定有更好,更简单的方式,对吗?我想过使用一个精选的案例,但是我不会想的更好。

应用程序是一个针对访问中的单个表运行的查询<数据库。每个复选框代表他们可以选择的每个字段,以便在表格或其他样式报告中显示
I''m having dificulty figuring out how to process multiple check boxes on a
web form.

Let''s say I have three check boxes:
cbox1
cbox2
cbox3

The only way I can think of to code the possibilities is something like:

If cbox1.checked = true then
.........
End if

If cbox2.checked = true then
......
End If

If cbox3.checked = true then
......
End if

If cbox1.checked = true and cbox2.checked = true then
......
end if

If cbox1.checked = true and cbox3.checked = true then
......
end if

And the If/End IFs go on forever!

As you can see, if I have around 8 check boxes, doing it this way could lead
to tremendous amounts of coding. I''m sure there''s a better, easier way,
right? I thought of using a select case but that wouldn''t be much better I
don''t think.

The application is a query that runs against a single table in an access
database. Each check box represents each field they could chose from to show
up in a table or other style report.




那么为什么你需要诸如


如果cbox1.checked = true而cbox2.checked = true那么......


你不能只是建立你的查询检查每个复选框

轮流?

Jan Hyde(VB MVP)


-

神秘:一匹年轻的马。 (Keith Nance)


[废除电视许可证 - http://www.tvlicensing.biz/]



Then why do you need conditions such as

If cbox1.checked = true and cbox2.checked = true then...

Can''t you just build up your query by checking each checkbox
in turn?


Jan Hyde (VB MVP)

--
Occult: A young horse. (Keith Nance)

[Abolish the TV Licence - http://www.tvlicensing.biz/]


那为什么你需要条件,如

如果cbox1.checked = true而cbox2.checked = true那么......

你不能通过勾选每个复选框来建立你的查询
反过来?

Jan Hyde(VB MVP)

-
神秘:一匹年轻的马。 (Keith Nance)

[废除电视许可证 - http:// www.tvlicensing.biz/]
Then why do you need conditions such as

If cbox1.checked = true and cbox2.checked = true then...

Can''t you just build up your query by checking each checkbox
in turn?
Jan Hyde (VB MVP)

--
Occult: A young horse. (Keith Nance)

[Abolish the TV Licence - http://www.tvlicensing.biz/]




我还是很喜欢编程,所以仍然想要编写代码

技术建立。我从来没有使用过复选框。


当你说你不能通过勾选每个复选框来建立你的查询

in转过来?,我不确定你的意思。你能举个例子吗?


谢谢Jan,

Jim



I''m still pretty new to programming so still trying to get some coding
techniques established. I''ve never worked with check boxes.

When you say "Can''t you just build up your query by checking each checkbox
in turn?", I''m not sure what you mean. Can you give me an example?

Thanks Jan,
Jim


这篇关于处理多个复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆