This is the 8th day of my participation in Gwen Challenge.More article challenges
Demand analysis
We are in life, in many places always need to use some lottery small program, or draw small program. So can we make such a program ourselves? The answer, of course, is yes.
In this article, I’ll make a raffle applet using C#. Very simple and practical, you can start to try.
function
Use C# to create a lottery program. Click start to scroll to show the lottery winner, end to show the winner.
making
1. Open VS and create a Windows Forms application
2. Select a project folder
According to their actual storage location, change.
3. Open the toolbox in the view and drag the relevant accessories to design the calculator page. Note that the name of the relevant buttons needs to be edited by yourself.
4. Double-click the relevant accessories to edit the code page.
I’m going to give it to you directly, and you should be aware that my component may not be the same as your own, so you can change it according to the name of your component.
Write a program
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApp1 { public partial class Form1 : Form {string [] the content = {" galen, "" Obama", "senna", "DE" levin, "Mr En", "her honey haired month", "blind monk", and "compression", "Annie"}; public Form1() { InitializeComponent(); } private void button1_Click(Object sender, EventArgs e) {if (button1.text == "start ") {button1.text =" end "; timer1.Start(); } else {button1.text = "start "; timer1.Stop(); } } private void timer1_Tick(object sender, EventArgs e) { Random r = new Random(); int i = r.Next(0, 8); label2.Text = content[i]; }}}Copy the code
Scan the QR code to obtain
More wonderful
Internet of Things knowledge
Click on it to see you look good
This article uses the article synchronization assistant to synchronize