基于Access数据库的抽奖系统设计
摘 要 介绍了抽奖信息管理系统的设计思路和基本原理,结合Access,通过软件系统开发,实现了具有随机性和相对均衡性的抽奖。 关键词 抽奖系统 Access VBA 随机 相对均衡性 引言 当今社会,各种各样的抽奖活动相当普遍,抽奖活动的基本原则和主要特征是随机性
摘 要 介绍了抽奖信息管理系统的设计思路和基本原理,结合Access,通过软件系统开发,实现了具有随机性和相对均衡性的抽奖。
关键词 抽奖系统 Access VBA 随机 相对均衡性
引言
当今社会,各种各样的抽奖活动相当普遍,抽奖活动的基本原则和主要特征是随机性,但对于某一团体内部的抽奖活动来说,还有一个相对均衡的问题,所谓相对均衡就是指让各个部门的中奖概率和其人数占总人数的比重大致相等。基于Access,结合其内置VBA语言,通过程序设计实现抽奖的随机,通过算法研究实现抽奖的相对均衡。本文主要介绍了系统原理以及主要程序的设计。
系统组成及原理
抽奖系统主要由来宾登记、奖票管理、幸运抽奖、获奖查询四个基本模块构成,登记模块登记参加抽奖人员,奖票管理模块初始化参加抽奖人员名单,抽奖模块实现抽奖功能,获奖查询模块查询获奖结果。其中,抽奖模块中可以实现奖励等级、总抽奖数、每一次抽奖数的控制。系统架构框图如图1。
图1 系统架构
系统初始化
来宾登记模块中已经收录了参加抽奖的人员名单以及所属部门,在奖票管理模块中,当点击初始化按钮时通过内部程序设计首先把上次的抽奖结果清空,同时利用 Rnd在参加抽奖的人员名单前随机生成一系列的序号,为幸运抽奖模块中的随机抽奖做准备[1]。主要初始化程序代码如下:
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
抽奖功能的实现
通过抽奖模块实现最终抽奖功能。
通过奖励等级组合框控制抽奖等级,通过抽奖数量组合框控制每批次抽奖数量,通过总抽奖数组合框控制总抽奖数。当奖励等级分别为一、二、三等奖时,抽奖数量和总抽奖数默认值分别
为5、10、10和10、30、50。各组合框的具体数值也可以通过上下箭头控制。抽奖界面如图2。
图 2 抽 奖 界 面
其程序设计比较简单,主要程序如下:
……
If Me!奖励等级.Value = 1 Then
Me!总数量.Value = 10
End If
If Me!奖励等级.Value = 2 Then
Me!总数量.Value = 30
End If
If Me!奖励等级.Value = 3 Then
Me!总数量.Value = 50
End If
Forms!抽奖.Q_抽奖统计.Requery
If Me!奖励等级.Value = 1 Then
Me!抽奖数量.Value = 5
End If
If Me!奖励等级.Value = 2 Or Me!奖励等级.Value = 3 Then
Me!抽奖数量.Value = 10
End If
……
通过点击开始按钮开始抽奖,同时按钮标题变为停止,再次点击停止此批次抽奖,同时按钮标题变为开始,继续点击开始下一批次抽奖,如此反复,直至完成总抽奖数,此时提示“抽奖总数已到”,如果未完成总抽奖数就开始另外一轮抽奖,则提示“抽奖限制”。
内部抽奖主要解决随机性和相对均衡两个问题。系统初始化在参加抽奖人员名单前随机生成了序号,通过查询“号码重排序”将参加抽奖人员名单按照序号升序排列,抽奖时按照序号顺序抽奖,实现了随机的要求。相对均衡要求大致按照各个部门人数占总人数的百分比来分配中奖人数,本系统采用各个部门占总人数的百分比乘以抽奖总数的方法来大致确定各个部门的中奖人数,有小数的数字通过程序设计进行四舍五入处理。需要注意的是,若使所有的部门中奖人数都要用四舍五入的方法进行处理则可能出现错误,为了避免这种情况需要选定一个部门,,使其中奖人数等于总抽奖数减去其他各个部门中奖人数之和[2]。抽奖模块的主要程序代码如下:
……
N = 0
cnt = Me!电科.Value + Me!电气.Value + Me!自动化.Value + Me!通信.Value + Me!院办.Value + Me!退休.Value
Do While Me!抽奖数量.Value > N And Not qrs.EOF And cnt
'电科抽奖
’四舍五入确定电科中奖数
If Me!电科.Value
If qrs.单位 = "电科" And qrs!批次.Value = 0 Then
Me!电科.Value = Me!电科.Value + 1
qrs.Edit
qrs!奖励等级.Value = Me!奖励等级.Value
qrs!批次.Value = Me!批次.Value
qrs.Update
N = N + 1
End If
Else
End If
……
'退休抽奖
cnt = Me!电科.Value + Me!电气.Value + Me!自动化.Value + Me!通信.Value + Me!院办.Value + Me!退休.Value
cnt2= Me!电科.Value + Me!电气.Value + Me!自动化.Value + Me!通信.Value + Me!院办.Value
'剩余数量分配给退休
If Me!退休.Value
If qrs22.单位 = "退休" And qrs!批次.Value = 0 Then
Me!退休.Value = Me!退休.Value + 1
qrs.Edit
qrs22!奖励等级.Value = Me!奖励等级.Value
qrs22!批次.Value = Me!批次.Value
qrs22.Update
N = N + 1
End If
Else
End If
……
’判断是否完成抽奖
cnt = Me!电科.Value + Me!电气.Value + Me!自动化.Value + Me!通信.Value + Me!院办.Value + Me!退休.Value
If cnt = Me!总数量.Value Then
MsgBox ("抽奖总数已到。")
Me.可抽奖.Value = 0
Else
MsgBox ("抽奖限制。")
End If
……
结论
本系统利用Access数据库,结合其内置VBA语言,探讨了系统初始化、抽奖的随机性和相对均衡性等关键问题,满足了抽奖的要求。进行适当调整,该系统可以应用于多种抽奖场合。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



On July 29, at the roll-off ceremony of AITO Wenjie's 400,000th new car, Yu Chengdong, Huawei's Managing Director, Chairman of Terminal BG, and Chairman of Smart Car Solutions BU, attended and delivered a speech and announced that Wenjie series models will be launched this year In August, Huawei Qiankun ADS 3.0 version was launched, and it is planned to successively push upgrades from August to September. The Xiangjie S9, which will be released on August 6, will debut Huawei’s ADS3.0 intelligent driving system. With the assistance of lidar, Huawei Qiankun ADS3.0 version will greatly improve its intelligent driving capabilities, have end-to-end integrated capabilities, and adopt a new end-to-end architecture of GOD (general obstacle identification)/PDP (predictive decision-making and control) , providing the NCA function of smart driving from parking space to parking space, and upgrading CAS3.0

DeepSeek cannot convert files directly to PDF. Depending on the file type, you can use different methods: Common documents (Word, Excel, PowerPoint): Use Microsoft Office, LibreOffice and other software to export as PDF. Image: Save as PDF using image viewer or image processing software. Web pages: Use the browser's "Print into PDF" function or the dedicated web page to PDF tool. Uncommon formats: Find the right converter and convert it to PDF. It is crucial to choose the right tools and develop a plan based on the actual situation.

According to news on July 12, the Honor Magic V3 series was officially released today, equipped with the new Honor Vision Soothing Oasis eye protection screen. While the screen itself has high specifications and high quality, it also pioneered the introduction of AI active eye protection technology. It is reported that the traditional way to alleviate myopia is "myopia glasses". The power of myopia glasses is evenly distributed to ensure that the central area of sight is imaged on the retina, but the peripheral area is imaged behind the retina. The retina senses that the image is behind, promoting the eye axis direction. grow later, thereby deepening the degree. At present, one of the main ways to alleviate the development of myopia is the "defocus lens". The central area has a normal power, and the peripheral area is adjusted through optical design partitions, so that the image in the peripheral area falls in front of the retina.

On April 11, Huawei officially announced the HarmonyOS 4.2 100-machine upgrade plan for the first time. This time, more than 180 devices will participate in the upgrade, covering mobile phones, tablets, watches, headphones, smart screens and other devices. In the past month, with the steady progress of the HarmonyOS4.2 100-machine upgrade plan, many popular models including Huawei Pocket2, Huawei MateX5 series, nova12 series, Huawei Pura series, etc. have also started to upgrade and adapt, which means that there will be More Huawei model users can enjoy the common and often new experience brought by HarmonyOS. Judging from user feedback, the experience of Huawei Mate60 series models has improved in all aspects after upgrading HarmonyOS4.2. Especially Huawei M

According to news on July 29, the Honor X60i mobile phone is officially on sale today, starting at 1,399 yuan. In terms of design, the Honor X60i mobile phone adopts a straight screen design with a hole in the center and almost unbounded ultra-narrow borders on all four sides, which greatly broadens the field of view. Honor X60i parameters Display: 6.7-inch high-definition display Battery: 5000mAh large-capacity battery Processor: Dimensity 6080 processor (TSMC 6nm, 2x2.4G A76+6×2G A55) System: MagicOS8.0 system Other features: 5G signal enhancement, smart capsule, under-screen fingerprint, dual MIC, noise reduction, knowledge Q&A, photography capabilities: rear dual camera system: 50 million pixels main camera, 2 million pixels auxiliary lens, front selfie lens: 8 million pixels, price: 8GB

According to news on May 13, vivoX100s was officially released tonight. In addition to excellent images, the new phone also performs very well in terms of signal. According to vivo’s official introduction, vivoX100s uses an innovative universal signal amplification system, which is equipped with up to 21 antennas. This design has been re-optimized based on the direct screen to balance many signal requirements such as 5G, 4G, Wi-Fi, GPS, and NFC. This makes vivoX100s the mobile phone with the strongest signal reception capability in vivo’s history. The new phone also uses a unique 360° surround design, with antennas distributed around the body. This design not only enhances the signal strength, but also optimizes various daily holding postures to avoid problems caused by improper holding methods.

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

According to news on July 19, Xiaomi MIX Fold 4, the first flagship folding new phone, was officially released tonight and is equipped with a "three-dimensional special-shaped battery" for the first time. According to reports, Xiaomi MIX Fold4 has achieved a major breakthrough in battery technology and designed an innovative "three-dimensional special-shaped battery" specifically for folding screens. Traditional folding screen devices mostly use conventional square batteries, which have low space utilization efficiency. In order to solve this problem, Xiaomi did not use the common winding battery cells, but developed a new lamination process to create a new form of battery, which greatly improved the space utilization. Battery Technology Innovation In order to accurately alternately stack positive and negative electrode sheets and ensure the safe embedding of lithium ions, Xiaomi has developed a new ultrasonic welding machine and lamination machine to improve welding and cutting accuracy.
