Lottery system design based on Access Database

Source: Internet
Author: User
Abstract: This paper introduces the design idea and basic principle of the lottery information management system. Based on Access and software system development, it realizes the random and relatively balanced lottery. Key words lottery system AccessVBA random relative equilibrium introduction in today's society, various Lottery activities are quite common. The basic principles and main features of lottery activities are randomness.

Abstract The design idea and basic principle of the lottery information management system are introduced. The random and relatively balanced lottery is achieved through software system development combined with Access. Keyword lottery system Access VBA random relative equilibrium introduction in today's society, various Lottery activities are quite common. The basic principles and main characteristics of lottery activities are randomness.

Abstract The design idea and basic principle of the lottery information management system are introduced. The random and relatively balanced lottery is achieved through software system development combined with Access.

Keyword lottery system Access VBA random relative equilibrium

Introduction

In today's society, various Lottery activities are quite common. The basic principles and main features of lottery activities are random. However, there is still a relatively balanced problem for lottery activities within a group, the so-called relative equilibrium means that the winning probability of each department is roughly equal to the proportion of the total number of members. Based on Access and its built-in VBA language, the program design is used to achieve random lottery drawing and the algorithm research is used to achieve a relatively balanced lottery drawing. This article mainly introduces the system principle and the design of the main program.

System composition and Principle

The lottery system consists of four basic modules: Guest registration, ticket management, Lucky Draw, and prize query. The registration module registers the participants in the lottery, and the lottery management module initializes the list of participants in the lottery, the lottery module provides the lottery function. The prize winning query module queries the prize winning results. The lottery module controls the reward level, total number of Lottery draws, and number of Lottery draws each time. System Architecture box.

System Architecture

System initialization

The guest registration module contains the list of participants and their respective departments. In the ticket management module, When you click the initialization button, use the internal program design to first clear the last lottery result, at the same time, Rnd is used to randomly generate a series of serial numbers before the list of people participating in the lucky draw, to prepare for the random lottery in the lucky draw module [1]. The main initialization code is as follows:

DoCmd. SetWarnings False

DoCmd. OpenQuery "delete Ticket No.", acNormal, acEdit

DoCmd. OpenQuery "APPEND Ticket No.", acNormal, acEdit

DoCmd. SetWarnings True

Set qrs = CurrentDb. OpenRecordset ("Vote number ")

Qrs. MoveFirst

I = 1

Do While Not qrs. EOF

Qrs. Edit

Qrs! Serial number = Int (211-1) * Rnd)

Qrs! Prize number = I

Qrs. Update

I = I + 1

Qrs. MoveNext

Loop

MsgBox ("the prize list is initialized. ")

Qrs. Close

Lottery implementation

The final lottery function is achieved through the lottery module.

Use the reward level combo box to control the lottery level, use the lottery quantity combo box to control the number of Lottery draws in each batch, and use the total lottery quantity combo box to control the total number of Lottery draws. When the reward levels are one, two, and three respectively, the number of Lottery draws and the total number of Lottery draws are default values respectively.

5, 10, 10, 10, 30, and 50. You can use the up and down arrows to control the specific values of each combo box. Lottery page 2.

Figure 2 awards

The program design is relatively simple. The main program is as follows:

......

If Me! Reward level. Value = 1 Then

Me! Total Quantity. Value = 10

End If

If Me! Reward level. Value = 2 Then

Me! Total Quantity. Value = 30

End If

If Me! Reward level. Value = 3 Then

Me! Total Quantity. Value = 50

End If

Forms! Lottery. Q _ lottery statistics. Requery

If Me! Reward level. Value = 1 Then

Me! Lottery quantity. Value = 5

End If

If Me! Reward level. Value = 2 Or Me! Reward level. Value = 3 Then

Me! Lottery quantity. Value = 10

End If

......

You can click the start button to start the lottery. At the same time, the title of the button changes to "stop", click "stop" again to start the lottery, and click "start" to start the next lucky draw, until the total number of Lottery draws is completed, the system prompts "the total number of Lottery draws has reached". If the total number of Lottery draws is not completed, another round of Lottery draws will be started, and the "lottery limit" will be prompted ".

The internal lottery mainly addresses the randomness and relative balance issues. The system generates a random serial number before the list of people participating in the lottery. by querying "number reordering", the list of people participating in the lottery is sorted in ascending order by serial number, achieve random requirements. The relative balance requirement is roughly based on the percentage of the number of people in each department to the total number of people, the system uses the percentage of each department to the total number of people multiplied by the total number of lottery to roughly determine the number of people in each department, digits with decimals are rounded to the nearest point by programming. It should be noted that an error may occur if the number of winners in all departments should be rounded down. To avoid this problem, you must select a department ,, make the number of winners equal to the total number of lotteries minus the total number of winners in other departments [2]. The main program code of the lottery module is as follows:

......

N = 0

Cnt = Me! Electronics. Value + Me! Electrical. Value + Me! Automation. Value + Me! Communication. Value + Me! Office. Value + Me! Retirement. Value

Do While Me! Lottery quantity. Value> N And Not qrs. EOF And cnt <Me! Total Quantity. Value

Electronic Science Lottery

Rounding to determine the number of electric science winners

If Me! Electronics. Value <(Int (Count of unit1. name/cnt1) * Me! Total number. Value + 0.5) And N <Me! Lottery quantity. Value And cnt <Me! Total Quantity. Value Then

If qrs. unit = "electrology" And qrs! Batch. Value = 0 Then

Me! Electronics. Value = Me! Electronics. Value + 1

Qrs. Edit

Qrs! Reward level. Value = Me! Reward level. Value

Qrs! Batch. Value = Me! Batch. Value

Qrs. Update

N = N + 1

End If

Else

End If

......

'Retirement Lottery

Cnt = Me! Electronics. Value + Me! Electrical. Value + Me! Automation. Value + Me! Communication. Value + Me! Office. Value + Me! Retirement. Value

Cnt2 = Me! Electronics. Value + Me! Electrical. Value + Me! Automation. Value + Me! Communication. Value + Me! Office. Value

'Remaining quantity allocated to retirement

If Me! Retirement. Value <Int (Me! Total Quantity. Value-cnt2) And N <Me! Lottery quantity. Value And cnt <Me! Total Quantity. Value Then

If qrs22. unit = "retired" And qrs! Batch. Value = 0 Then

Me! Retirement. Value = Me! Retirement. Value + 1

Qrs. Edit

Qrs22! Reward level. Value = Me! Reward level. Value

Qrs22! Batch. Value = Me! Batch. Value

Qrs22.Update

N = N + 1

End If

Else

End If

......

'Judge whether the lottery is completed

Cnt = Me! Electronics. Value + Me! Electrical. Value + Me! Automation. Value + Me! Communication. Value + Me! Office. Value + Me! Retirement. Value

If cnt = Me! Total Quantity. Value Then

MsgBox ("the total number of Lottery draws has arrived. ")

Me. Lucky Draw. Value = 0

Else

MsgBox ("Lucky Draw restrictions. ")

End If

......

Conclusion

The system uses the Access database and its built-in VBA language to discuss key issues such as system initialization, randomness and relative balance of lottery drawing, and meets the requirements of lottery drawing. The system can be used for multiple lottery occasions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.