如何加载随机表单而不重复两次相同的表单? [英] How do I load a random form without repeating the same form twice?

查看:82
本文介绍了如何加载随机表单而不重复两次相同的表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在用vb.net进行测验

请帮帮我



我尝试了什么:



到目前为止,我只尝试过选择类rnd.Next(0,5)

解决方案

别。使用一个表单,但随机加载到其中的数据 - 不要尝试为每个问题创建一个新表单!



然后它很简单:创建一个集合问题,答案(或答案),并在您的应用程序中记录您已经问过的问题。这并不困难 - 最简单的方法是创建一个文本文件,每个问题都有一行,问题和答案用'|'字符分隔:

 question | CorrectAnswerNumber | Answer1 | Answer2 | Answer3 
问题| CorrectAnswerNumber | Answer1 | Answer2 | Answer3
问题| CorrectAnswerNumber | Answer1 | Answer2 | Answer3
...

然后你可以阅读使用File.ReadAllLines将它们全部转换为String数组,并使用string.Split将每一行分成问题和答案。

保留单独的问题编号集合,然后您可以选择一个问题从字符串数组中随机出现。拆分该行,并填写当前表格中的字段。



但是......这是你的作业,所以我不会给你任何密码! />
如果您稍微考虑一下并尝试一些实验,这很简单。


I've been making a quiz using vb.net
Please help me

What I have tried:

So far I have only tried the Select class rnd.Next (0, 5)

解决方案

Don't. Use one form, but randomise the data you load into it - don't try to create a new form for each question!

Then it's pretty simple: create a set of questions, with the answer (or answers) and keep a record in your app of which questions you have already asked. That's not difficult - the simplest way is to create a text file which has a line per question, with questions and answers separated by '|' characters:

question|CorrectAnswerNumber|Answer1|Answer2|Answer3
question|CorrectAnswerNumber|Answer1|Answer2|Answer3
question|CorrectAnswerNumber|Answer1|Answer2|Answer3
...

You can then read them all into an Array of String using File.ReadAllLines, and separate each line into questions and answers using string.Split.
Keep a separate collection of question numbers you have asked, and you can select a question at random from the array of strings. Split that line, and fill in the fields on the current form.

But... this is your homework, so I'll give you no code!
It's pretty simple if you think about it for a bit and try a few experiments.


这篇关于如何加载随机表单而不重复两次相同的表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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