如何得到3个单选按钮和msg.box的答案(你得到了正确的答案)或(错误的答案) [英] how to get the answer of 3 radio buttons and msg.box ( you got correct answer) or ( wrong answer)

查看:72
本文介绍了如何得到3个单选按钮和msg.box的答案(你得到了正确的答案)或(错误的答案)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在进行测验,c#windows表单应用程序,登录代码,以5个问题开始测验



1个问题ex:



什么颜色的球?



radiobutton1 - 白色(正确答案)



radiobutton2 - 黑色



radiobutton3 - 黄色



当我按下时表格怎么样旁边的按钮告诉我,如果我做出正确的答案,我有5个问题的5个表格,并在最后的表格,以计算所有问题的前。你有3个正确的和2个错误的...



任何人都可以帮我这个...



谢谢

Im making a quiz, c# windows form application, a login code, starting the quiz with 5 question

1 question ex:

what color is a ball?

radiobutton1 - white ( correct answer)

radiobutton2 - black

radiobutton3 - yellow

how can in the form when i presss a button next to tell me if i made a right answer, i have 5 forms for 5 question, and at the end form to count all the question for ex. you have made 3 correct and two wrong...

can anyone help me with this...

thanks

推荐答案

你怎么这么做很难说,因为我们不知道你的系统的其余部分是如何工作的。但是,这就是我要做的:

创建一个存储问题和答案的存储介质:这可以是数据库,xml文件,电子表格,甚至是文本文件。基本上你可以从中获取数据,你可以从中检索数据。

每个问题都有一个问题文本(什么颜色是球?)和正确答案(白色)和一些错误的答案 - 这可能是两个,或者你可以有更多并随机选择其中两个。

然后,对于每个问题,我会使用Random类给我一个数字然后放右在该radioButton.Text字段中回答 - 并将控件的Tag字段设置为true。另外两个单选按钮会得到错误的答案,并且标签为false。

按下按钮时,找到所选的单选按钮,并检查它的标签 - 如果确实如此,他们就是正确的。 br />


简单!
Exactly how you do this is difficult to say, since we have no idea how the rest of your system works. But, this is what I would do:
Create a storage medium that holds questions and answers: this could be a database, xml file, spreadsheet, or even a text file. Basically anything you are happy with that you can retrieve data from.
Each question would have a question text ("What colour is a ball?") and right answer ("White") and a number of wrong answers - this could be two, or you could have more and randomly select two of them.
Then, for each question, I'd use the Random class to give me a number and put the right answer in that radioButton.Text field - and set the Tag field of the control to "true". The other two radio buttons would get wrong answers, and a Tag of false.
When the button is pressed, find the selected radio button, and check it's Tag - if it's true they got it right.

Simple!


您可以在这里使用许多可能的实现方式,并且OriginalGriff为您提供了很好的建议。 />


一个关键问题是:你的目标是什么?创建一个一次性解决方案,其中所有逻辑和事件都发生在一个Windows窗体中?或者,创建一个可以在其他项目中重复使用的通用解决方案,并且可以添加新功能(可扩展性)?



具体建议,无论你的目标是一次性或可重复使用:不要为每个问题使用单独的表格:



1.使用单个Panel或其他ContainerControl来保持您需要的RadioButtons和其他控件,并重新使用这些控件,更改每个问题的内容。



2.如果您有每个问题独有的其他内容(图片?),您可以考虑使用TabControl,每个TabPage上的每个问题都有唯一的内容。



3. fyi:另一种检查一个RadioButton的方法random是在每个问题开始时将所有RadioButtons的Checked值设置为false。这可以避免参加测试的人略微无意识地偏向于将检查值视为可能更可能是正确的。



4.如果你的目标是一个可重复使用的解决方案,考虑使用类,模拟问题/答案的集合,以及个别问题/答案。如果你愿意,可以在这里寻求帮助。
There are many possible ways of implementation you could use here, and OriginalGriff has given you excellent suggestions.

A key question is: what is your goal here ? To create a one-off solution where all the logic and events happen in one Windows Form ? Or, to create a general solution that you can re-use in other projects, and to which you can add new features (extensibility) ?

Specific suggestions, whether your goal is one-off, or re-usable: don't use a separate Form for each question:

1. use a single Panel, or other ContainerControl, to hold the RadioButtons and other Controls you need, and re-use those Controls, changing their content for each question.

2. if you had additional content unique to each question (a picture ?), you could consider using a TabControl, with unique content for each question on each TabPage.

3. fyi: an alternative to checking one RadioButton at random is to set the Checked value of all RadioButtons to 'false at the start of each question. this may avoid a slight unconscious bias of the person taking the test to consider the checked value as being, possibly, more likely to be correct.

4. if your goal is a re-usable solution, consider using classes, to "model" both the collection of Questions/Answers, and individual Question/Answers. ask for help here with that, if you wish.


你好,

当用户选择答案并点击下一个按钮时检查答案是否正确,如果是正确的话向会话添加计数并打开下一个表单,如果答案正确,则在下一个表格中增加计数。
Hello,
When user selects the answer and hits next button check for correct answer, if it is correct add a count to session and open next form, in next forms increment count if answer is correct.


这篇关于如何得到3个单选按钮和msg.box的答案(你得到了正确的答案)或(错误的答案)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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