資源簡介
通過VS2103 編寫,簡單的抽簽小程序,實測可用
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
using?System.IO;
using?System.Collections;
//Download?by?http://www.codesc.net
namespace?抽簽系統
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????string[]?nameList;
????????private?void?button2_Click(object?sender?EventArgs?e)
????????{
????????????OpenFileDialog?file?=?new?OpenFileDialog();
????????????file.Filter?=?“(*.txt)|*.txt“;
????????????file.ShowDialog();
????????????if?(file.FileName?==?““)
????????????{
????????????????return;
????????????}
????????????StreamReader?reader?=?new?StreamReader(file.FileName);
????????????string?line;
????????????line?=?reader.ReadLine();
????????????int?nameNum?=?0;
????????????while?(line?!=?null)
????????????{
????????????????line?=?reader.ReadLine();
????????????????nameNum++;
????????????}
????????????reader.Close();
????????????nameList?=?new?string[nameNum];
????????????reader?=?new?StreamReader(file.FileName?UnicodeEncoding.GetEncoding(“GB2312“));
????????????line?=?reader.ReadLine();
????????????int?i?=?0;
????????????while?(line?!=?null)
????????????{
????????????????nameList[i++]?=?line;
????????????????line?=?reader.ReadLine();
????????????}
????????????reader.Close();
????????????for?(i?=?0;?i?????????????{
????????????????listBox1.Items.Add(nameList[i]);
????????????}????????????
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????if?(listBox2.Items.Count?==?nameList.Length)
????????????{
????????????????MessageBox.Show(“名單全部都被抽中,不用再抽簽了“);
????????????????return;
????????????}
????????????bool?flag?=?true;
????????????Random?random?=?new?Random();?????????????
????????????int?igeted=0?num?=?nameList.Length;
????????????geted?=?random.Next(0?num);
????????????if?(listBox2.Items.Count?==?0)
????????????{
????????????????listBox2.Items.Add(nameList[geted]);
????????????????return;
????????????}
???
????????????while?(flag?==?true)
????????????{
????????????????flag?=?false;
????????????????geted?=?random.Next(0?num);
????????????????if?(geted?==?12)
????????????????????geted?=?12;
????????????????for?(i?=?0;?i?????????????????{
????????????????????if?(nameList[geted]?==?listBox2.Items[i].ToString())
????????????????????????flag?=?true;
????????????????}
????????????}
???????????listBox2.Items.Add(nameList[geted]);
????????????
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????145??2014-02-27?21:35??codesc.net\抽簽系統\抽簽系統\bin\Debug\namelist1.txt
?????文件????????146??2014-02-27?21:35??codesc.net\抽簽系統\抽簽系統\bin\Debug\namelist2.txt
?????文件????????138??2014-03-01?21:10??codesc.net\抽簽系統\抽簽系統\bin\Debug\namelist3.txt
?????文件??????15360??2014-03-01?21:22??codesc.net\抽簽系統\抽簽系統\bin\Debug\抽簽系統.exe
?????文件???????2722??2018-06-13?11:52??codesc.net\抽簽系統\抽簽系統\Form1.cs
?????文件???????4882??2018-06-13?11:52??codesc.net\抽簽系統\抽簽系統\Form1.Designer.cs
?????文件???????5814??2014-02-28?16:15??codesc.net\抽簽系統\抽簽系統\Form1.resx
?????文件???????4316??2018-06-13?11:52??codesc.net\抽簽系統\抽簽系統\Form2.cs
?????文件??????10484??2014-03-01?21:21??codesc.net\抽簽系統\抽簽系統\Form2.Designer.cs
?????文件???????6008??2014-03-01?21:21??codesc.net\抽簽系統\抽簽系統\Form2.resx
?????文件????????473??2014-02-28?18:31??codesc.net\抽簽系統\抽簽系統\Program.cs
?????文件???????1356??2014-02-28?16:10??codesc.net\抽簽系統\抽簽系統\Properties\AssemblyInfo.cs
?????文件???????2874??2014-02-28?16:10??codesc.net\抽簽系統\抽簽系統\Properties\Resources.Designer.cs
?????文件???????5612??2014-02-28?16:10??codesc.net\抽簽系統\抽簽系統\Properties\Resources.resx
?????文件???????1097??2014-02-28?16:10??codesc.net\抽簽系統\抽簽系統\Properties\Settings.Designer.cs
?????文件????????249??2014-02-28?16:10??codesc.net\抽簽系統\抽簽系統\Properties\Settings.settings
?????文件???????3695??2014-02-28?18:31??codesc.net\抽簽系統\抽簽系統\抽簽系統.csproj
?????文件????????926??2014-02-28?16:10??codesc.net\抽簽系統\抽簽系統.sln
?????文件??????15360??2014-03-01?21:27??codesc.net\抽簽系統\抽簽系統.suo
?????目錄??????????0??2018-06-13?11:52??codesc.net\抽簽系統\抽簽系統\bin\Debug
?????目錄??????????0??2018-06-13?11:50??codesc.net\抽簽系統\抽簽系統\bin
?????目錄??????????0??2018-06-13?11:50??codesc.net\抽簽系統\抽簽系統\Properties
?????目錄??????????0??2018-06-13?11:52??codesc.net\抽簽系統\抽簽系統
?????目錄??????????0??2018-06-13?11:50??codesc.net\抽簽系統
?????目錄??????????0??2018-06-13?11:51??codesc.net
-----------?---------??----------?-----??----
????????????????81657????????????????????25
- 上一篇:C# 紙飛機大作戰 游戲源碼
- 下一篇:C#與正運動控制卡
評論
共有 條評論