Lottery system design based on Access Database (1)

Source: Internet
Author: User

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

: Lottery page


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.