现在有很多彩票软件神乎其神,但归根到底都是随机数的使用。我们用6位随机数来演示在c#中使用随机数 从而自己制作自己的彩票软件:) -------------------------------- 代码如下 /* 这是一个简单的随机数使用 * 2004年3月29日 */ using system; using system.drawing; using system.collections; using system.componentmodel; using system.windows.forms; using system.data;
namespace mylotteryproject { /// <summary> /// summary description for form1. /// </summary> public class mylotteryform : system.windows.forms.form { /// <summary> /// required designer variable. /// </summary>
public mylotteryform() { // // required for windows form designer support // initializecomponent(); // // todo: add any constructor code after initializecomponent call // }
/// <summary> /// clean up any resources being used. /// </summary> protected override void dispose( bool disposing ) { if( disposing ) { if (components != null) { components.dispose(); } } base.dispose( disposing ); }
#region windows form designer generated code /// <summary> /// required method for designer support - do not modify /// the contents of this method with the code editor. /// </summary>
private void initializecomponent() { system.resources.resourcemanager resources = new
system.resources.resourcemanager(typeof(mylotteryform)); this.textbox1 = new system.windows.forms.textbox(); this.textbox2 = new system.windows.forms.textbox(); this.textbox3 = new system.windows.forms.textbox(); this.textbox4 = new system.windows.forms.textbox(); this.textbox5 = new system.windows.forms.textbox(); this.textbox6 = new system.windows.forms.textbox(); this.pbnextdraw = new system.windows.forms.button(); this.label1 = new system.windows.forms.label(); this.label2 = new system.windows.forms.label(); this.labeldaytime = new system.windows.forms.label(); this.label3 = new system.windows.forms.label(); this.label4 = new system.windows.forms.label(); this.pbend = new system.windows.forms.button(); this.label5 = new system.windows.forms.label(); this.pbsort = new system.windows.forms.button(); this.labelsort = new system.windows.forms.label(); this.picturebox1 = new system.windows.forms.picturebox(); this.picturebox3 = new system.windows.forms.picturebox(); this.picturebox4 = new system.windows.forms.picturebox(); this.label6 = new system.windows.forms.label(); this.suspendlayout(); // // textbox1 // this.textbox1.backcolor = system.drawing.color.magenta; this.textbox1.location = new system.drawing.point(106, 190); this.textbox1.name = "textbox1"; this.textbox1.readonly = true; this.textbox1.size = new system.drawing.size(28, 21); this.textbox1.tabindex = 0; this.textbox1.text = "textbox1"; // // textbox2 // this.textbox2.backcolor = system.drawing.color.gold; this.textbox2.location = new system.drawing.point(144, 190); this.textbox2.name = "textbox2"; this.textbox2.readonly = true; this.textbox2.size = new system.drawing.size(29, 21); this.textbox2.tabindex = 1; this.textbox2.text = "textbox2"; // // textbox3 // this.textbox3.backcolor = system.drawing.color.cyan; this.textbox3.location = new system.drawing.point(182, 190); this.textbox3.name = "textbox3"; this.textbox3.readonly = true; this.textbox3.size = new system.drawing.size(29, 21); this.textbox3.tabindex = 2; this.textbox3.text = "textbox3"; // // textbox4 // this.textbox4.backcolor = system.drawing.color.red; this.textbox4.location = new system.drawing.point(221, 190); this.textbox4.name = "textbox4"; this.textbox4.readonly = true; this.textbox4.size = new system.drawing.size(29, 21); this.textbox4.tabindex = 3; this.textbox4.text = "textbox4"; // // textbox5 // this.textbox5.backcolor = system.drawing.color.yellow; this.textbox5.location = new system.drawing.point(259, 190); this.textbox5.name = "textbox5"; this.textbox5.readonly = true; this.textbox5.size = new system.drawing.size(29, 21); this.textbox5.tabindex = 4; this.textbox5.text = "textbox5"; // // textbox6 // this.textbox6.backcolor = system.drawing.color.lime; this.textbox6.location = new system.drawing.point(298, 190); this.textbox6.name = "textbox6"; this.textbox6.readonly = true; this.textbox6.size = new system.drawing.size(28, 21); this.textbox6.tabindex = 5; this.textbox6.text = "textbox6"; // // pbnextdraw // this.pbnextdraw.backcolor = system.drawing.color.palegoldenrod; this.pbnextdraw.cursor = system.windows.forms.cursors.hand; this.pbnextdraw.flatstyle = system.windows.forms.flatstyle.flat; this.pbnextdraw.font = new system.drawing.font("microsoft sans serif", 12f,
system.drawing.fontstyle.bold, system.drawing.graphicsunit.point, ((system.byte)(0))); this.pbnextdraw.forecolor = system.drawing.color.goldenrod; this.pbnextdraw.location = new system.drawing.point(10, 250); this.pbnextdraw.name = "pbnextdraw"; this.pbnextdraw.size = new system.drawing.size(211, 43); this.pbnextdraw.tabindex = 6; this.pbnextdraw.text = "下一注 >"; this.pbnextdraw.click += new system.eventhandler(this.pbnextdraw_click); // // label1 // this.label1.backcolor = system.drawing.color.coral; this.label1.font = new system.drawing.font("comic sans ms", 18f,
system.drawing.fontstyle.bold, system.drawing.graphicsunit.point, ((system.byte)(0))); this.label1.location = new system.drawing.point(38, 17); this.label1.name = "label1"; this.label1.size = new system.drawing.size(384, 43); this.label1.tabindex = 7; this.label1.text = "infofox.org彩票软件 .net0.01v"; // // label2 // this.label2.font = new system.drawing.font("microsoft sans serif", 12f,
system.drawing.fontstyle.bold, system.drawing.graphicsunit.point, ((system.byte)(0))); this.label2.forecolor = system.drawing.color.indianred; this.label2.location = new system.drawing.point(29, 129); this.label2.name = "label2"; this.label2.size = new system.drawing.size(211, 25); this.label2.tabindex = 8; this.label2.text = "买6个数字肯定可以中奖"; // // labeldaytime // this.labeldaytime.font = new system.drawing.font("microsoft sans serif", 12f,