This paper introduces the design idea and basic principle of lottery information management system, combining access, through software system development, realizes the lottery with randomness and relative equalization.
keyword lottery system Access VBA random relative equalization
Introduction
Today's society, a wide variety of lottery activities are quite common, the basic principles of lottery and the main characteristics of randomness, but for a group within the lottery, there is a relatively balanced problem, the so-called relative equilibrium means that the probability of winning each department and its number of the total number of shares roughly equal. Based on access, combined with its built-in VBA language, through the program design to achieve the random lottery, through the algorithm research to achieve the relative balance of the lottery. This paper mainly introduces the system principle and the design of the main program.
System composition and principle
Lottery system mainly by the guest registration, ticket management, Lucky Draw, award-winning query four basic modules, registration module registration to participate in the lottery, ticket management module initialization to participate in the draw list, lottery module to achieve the lottery function, the award-winning Query Module query award results. Among them, the lottery module can realize the reward level, the total draw number, each lottery number control. The system architecture diagram is shown in Figure 1.
Figure 1 System architecture
System initialization
Guest Registration module has included the list of people to participate in the lottery and the department, in the award management module, when the click of the initialization button through the internal program design first of the last lottery results empty, while using Rnd in the lottery before the list of people randomly generated a series of serial numbers, Prepare for the random draw in the lucky draw module [1]. The main initialization program code is as follows:
DoCmd.SetWarnings False
DoCmd.OpenQuery "删除对奖票号", acNormal, acEdit
DoCmd.OpenQuery "追加对奖票号", acNormal, acEdit
DoCmd.SetWarnings True
Set qrs = CurrentDb.OpenRecordset("对奖票号")
qrs.MoveFirst
i = 1
Do While Not qrs.EOF
qrs.Edit
qrs!序号 = Int((211 - 1) * Rnd)
qrs!对奖号码 = i
qrs.Update
i = i + 1
qrs.MoveNext
Loop
MsgBox ("对奖名单初始化完毕。")
qrs.Close
The realization of lottery function
Through the lottery module to achieve the final lottery function.
Through the reward Level combo box to control the draw level, through the lottery number combo box to control the number of lottery, through the total Draw Number combo box control total draw number. When the reward grade is one or two, the third prize, the lottery number and the total draw number default value respectively
are 5, 10, 10 and 10, 30, 50. The specific values of each combo box can also be controlled by up and down arrows. Draw the interface as shown in Figure 2.
Figure 2 Lottery interface