| |

VerySource

 Forgot password?
 Register
Search
View: 1470|Reply: 11

Lottery system for help

[Copy link]

2

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-29 20:30:02
| Show all posts |Read mode
I am doing a lottery system for the unit
The general approach is
Enter employee information into database
Click event with a button
Start FOR loop statement
Displaying data with LABEL.TEXT

But now just a little start button
It keeps looping
Other buttons are unclickable

How to write can achieve
Click button one to start the loop
Click on button two
Reply

Use magic Report

0

Threads

58

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 Invalid IP Address

Post time: 2020-5-9 11:45:01
| Show all posts
Button 1: Start a thread draw.
Reply

Use magic Report

0

Threads

10

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-5-10 13:15:01
| Show all posts
Just add a judgment to the loop body. .

Determine if you clicked the second button.

for ......
if condition then
 exit fot
endif
next
Reply

Use magic Report

0

Threads

10

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-5-10 13:45:02
| Show all posts
fot is wrong and should be for
Reply

Use magic Report

2

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-5-10 20:45:01
| Show all posts
thank you
But I am really a novice

May I ask this statement to judge the second button
How to write
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-5-12 10:45:01
| Show all posts
Use multithreading
How to do a thread, the interface is deadlocked
Reply

Use magic Report

0

Threads

11

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-5-13 21:00:01
| Show all posts
Using timer is very simple, put the numbers you want to draw into the numbers array.

 private string [] numbers = null;
The
private void btnStart_Click (object sender, System.EventArgs e)
{
this.timer1.Interval = 100;
this.timer1.Start ();
this.btnStart.Enabled = false;
this.btnStop.Enabled = true;
}

private void Form1_Load (object sender, System.EventArgs e)
{
numbers = new string [] {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"};
this.timer1.Tick + = new System.EventHandler (this.timer1_Tick);
this.btnStart.Enabled = true;
this.btnStop.Enabled = false;
}

private void timer1_Tick (object sender, EventArgs e)
{
this.txtNumber.Text = GetRandomNumber (this.numbers);
}

private string GetRandomNumber (string [] numbers)
{
if (numbers == null || numbers.Length == 0)
return "";
Random rdm = new Random (unchecked ((int) DateTime.Now.Ticks));
int index = rdm.Next (0, numbers.Length-1);
return numbers [index];
}

private void btnStop_Click (object sender, System.EventArgs e)
{
this.timer1.Stop ();
this.btnStart.Enabled = true;
this.btnStop.Enabled = false;
}
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 Invalid IP Address

Post time: 2020-5-15 11:00:01
| Show all posts
The landlord, the circulation of the lottery is unscientific, and it should be better to use random. The Random function can solve it (for example, use the timer control to randomly draw one in 0.1 seconds and click the button to confirm).
Reply

Use magic Report

0

Threads

11

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-5-15 14:15:01
| Show all posts
In addition, after a number is drawn, the number should be removed from the array to avoid repeated winnings ~~
Reply

Use magic Report

0

Threads

10

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-5-27 22:00:01
| Show all posts
You post your code, let me change it
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list