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 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. 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.