用vb制作随机点名器

合集下载

VB写的随机点名器代码

VB写的随机点名器代码

不是我写‎的,在其它‎网页上粘贴‎来的。

看了‎李冬梅老师‎的信息及其‎特征这堂课‎发现原来一‎个小小的点‎名器可以很‎好的让学生‎集中注意力‎,跟着老师‎的思路走,‎所以学一下‎。

V‎B写的随机‎点名器代码‎''+‎+++++‎+++++‎+++++‎+++++‎+++++‎+++++‎+++++‎+++++‎+++++‎+++++‎+++++‎+++'‎1、新建一‎个工程;‎'2、在窗‎体Form‎1内放入L‎a bel1‎、Time‎r1、Co‎m mand‎1、Com‎m and2‎四个控件;‎'3、把‎以下代码直‎接复制到你‎的工程里;‎'4、在‎工程所在的‎文件夹里新‎建一个文本‎文件“N.‎t xt”,‎把名字写入‎文件,一行‎一个名字。

‎'+++‎+++++‎+++++‎+++++‎+++++‎+++++‎+++++‎+++++‎+++++‎+++++‎+++++‎+++++‎+'‎'代码虽简‎单,'为‎你解忧烦,‎'写码伤‎脑筋,'‎占用我一晚‎;'每每‎向钱看,‎'钱包总受‎伤,'拷‎完顶一顶,‎'就算帮‎个忙。

(这‎是编程的作‎者写的,前‎面挺押韵,‎也挺有意思‎,呵呵。

)‎'O‎p tion‎Expl‎i cit‎‎D im T‎e mp A‎s Str‎i ng‎ Di‎m Nam‎e Txt(‎5000)‎As S‎t ring‎‎'存储从“‎N.txt‎”中逐行读‎取的内容,‎如果大于5‎000条记‎录请更改为‎更大的数字‎。

‎Dim ‎i As ‎L ong‎ D‎i m Lc‎As L‎o ng ‎ '‎N.txt‎中的记录总‎数(文本行‎数)‎ Dim‎x As‎Long‎‎ ' 存‎储随机数‎P‎r ivat‎e Sub‎Comm‎a nd1_‎C lick‎()‎ i =‎0‎ Lc ‎= 0‎ x ‎= 999‎999‎ Op‎e n Ap‎p.Pat‎h & "‎\N.tx‎t" Fo‎r Inp‎u t As‎#1 ‎ '数一‎数“N.t‎x t”中有‎几个记录。

基于VB和SpeechSDK的课堂随机语音点名系统设计_刘杰

基于VB和SpeechSDK的课堂随机语音点名系统设计_刘杰
参考文献 : [ ] ] ( ) : 1 J .考试周刊 , 2 0 1 2 4 2 1 6 8. 王海鸥 ,徐刚 .高校课堂点名制度研究 [ [ ] 北京 : 人民邮电出版社 , 2 i s u a l B a s i c 6. 0 程序设计与开发技术大全 [ M] . 2 0 0 4: 1 2 3. 求是科技 .V - [ ] ] ( ) : 刘慧婷 . 基于 V 3 B 的学生成绩管理系统的设计与实现 [ J .计算机技术与发展 , 2 0 0 7, 1 7 1 2 1 6 9 1 7 2. 王佩红 , - [ ] ] ( ) : 周风余 . 基于 S 自然科学版 , 4 e e c h S D K 的机器人语音交互系统设计 [ J .北京联合大学学报 : 2 0 1 0, 2 4 1 陈景帅 , p 2 5 2 9. -
DOI:10.13797/ki.jfosu.1008-0171.2014.0030
点名制度是高等院校普遍采用的维持学生到课率的方法 , 但经常 性 点 名 往 往 会 起 到 以 下 两 个 方 面
1] 。 的反作用 [
) ( 经常性点名会挤占正常的教学时间 , 从而影响教学工作的完成 。 1 ( ) 经常性点名可能会引起学生的反感 , 甚至会让爱学习的学生产生老师故意浪费课堂时间这样的 2 误解 。 为改善这一状况 , 本文基于 V B和 S e e c h S D K 设计了一种课堂随机语音点名系统。该系统采用 p 能够有效控制点名的时间消耗 。 此外 , 将 该 系 统 与 课 堂 提 问 相 结 合, 还能起 完全随机的方式进行点名 , 到活跃课堂气氛 、 提高学习热情的作用 。
: A b s t r a c t A k i n d o f r a n d o m v o i c e r o l l c a l l s s t e m i s d e s i n e d b a s e d o n V B a n d S e e c h S D K. T h e s s - y g p y , t e m c r e a t e s t h e r o l l c a l l l i s t f r o m t h e t e x t f o r m a t l i s t o f s t u d e n t s s e l e c t s a s t u d e n t r a n d o m l a n d r e a d s y , t h e n a m e a n d t h e s t u d e n t n u m b e r a l o u d . I n o r d e r t o a v o i d r e c u r r e n t s e l e c t i o n a k i n d o f d u a l l i s t i s t o s t o r e t h e s e l e c t i o n t e m o r a r i l . T h e o f v o i c e b r o a d c a s t i n o f s t u d e n t n u m b e r i s s o l v e d u s e d r o b l e m p y g p b i n s e r t i n b l a n k i n t o a d a c e n t n u m b e r s . T h e s s t e m h a s b e e n i n t o u s e i n t h e c l a s s r o o m a n d o b u t - y g j y p t a i n e d o o d r e s o n s e . g p : ; ;V K e w o r d sr a n d o m v o i c e c a l l v o i c e b r o a d c a s t i n o f s t u d e n t n u m b e r B; S e e c h S D K g p y

随机点名器的设计

随机点名器的设计

右边按钮的“点击”事件代码为
thisform.timer2.enabled=.t. bel1.caption=" "
Timer1的Timer事件代码
s=thisform.edit1.value &&读取编辑框到字符串s n=occurs(chr(13),s) &&统计编辑框中的总行数 k=int(rand()*n)+1 &&产生随机数k:1...n if k>1
左边按钮的“点击”事件代码为
if this.caption=="开始(\<S)" thisform.timer1.enabled=.t. this.caption="停止(\<S)"
else thisform.timer1.enabled=.f. this.caption="开始(\<S)" endif
thisform.edit1.setfocus
mand1.enabled=.f.
endif
else
if thisform.width>370 &&设表单收拢到宽度370
thisform.width=thisform.width-10 &&收拢窗体右边
else
this.enabled=.f.
&&收拢停止
this.tag="0"
&&设已收拢标志
mand2.caption="输入名单"
s=thisform.edit1.value &&读取编辑框到字符串s
n=occurs(chr(13),s) &&统计编辑框ed=.t.

VB编写的课堂随机点名小程序代码

VB编写的课堂随机点名小程序代码

随机点名系统。

综合网上各类小程序,自己修改定制了一款新的小程序。

学生名单.txt 放在同一个目录中。

使用截图如下Private Declare Sub SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)'定义常量Const HWND_TOPMOST = -1 'On TopConst HWND_NOTOPMOST = -2 'No TopConst SWP_NOACTIV A TE = &H10 'Const SWP_SHOWWINDOW = &H40 ''Dim TopOn As IntegerDim ss, mm, nnDim num(1 To 300) As IntegerDim j, k As IntegerDim A(500) As String, r As IntegerDim filename As StringPrivate Sub Command1_Click()Dim b As StringDim t, i As Integerfilename = App.Path & "\" & "学生名单.txt" Open filename For Input As #1'产生记录总数以内的随机数xi = 1While Not EOF(1)Line Input #1, A(i)i = i + 1Wendc = iClose #1Start:Randomizet = Int(c * Rnd + 1)For j = 1 To cIf t = num(j) ThenGoTo StartEnd IfNextLabel1.Caption = A(t)k = k + 1num(k) = tIf k = c ThenMsgBox "所有人员均已点过!", vbSystemModal Command1.Enabled = FalseCommand3.Enabled = TrueEnd IfEnd SubPrivate Sub Command2_Click()Unload Form1End SubPrivate Sub Command3_Click()j = 0k = 0For i = 1 To 300num(i) = 0NextCommand3.Enabled = FalseCommand1.Enabled = TrueLabel1.Caption = "Name"End SubPrivate Sub Command4_Click()Timer1.Enabled = TrueCommand4.Enabled = FalseEnd SubPrivate Sub Data1_Validate(Action As Integer, Save As Integer) End SubPrivate Sub Form_load()Form1.Height = 500Form1.Width = 8550Command3.Enabled = FalseTimer1.Enabled = Falsemm = 45: ss = 0Timer1.Interval = 1000End SubPrivate Sub Timer1_Timer()Dim M As IntegerSetWindowPos Me.hwnd, HWND_TOPMOST, Me.Left / 15, _Me.Top / 15, Me.Width / 15, _Me.Height / 15, SWP_NOACTIV ATE Or SWP_SHOWWINDOW Line1:If ss < 10 Thens = "0" & ssElses = ssEnd IfIf mm < 10 Thenmmm = "0" & mmElsemmm = mmEnd Ift = mmm & ":" & sLabel2.Caption = tss = ss - 1If nn = 3 Thenss = 88End IfIf mm = 0 And ss = -1 And nn = 0 ThenMsgBox "休息时间已到,五分钟后继续", vbSystemModalnn = 1mm = 5: ss = 0GoTo Line1End IfIf mm = 0 And ss = -1 And nn = 1 ThenMsgBox "继续上课", vbSystemModalnn = 2mm = 45: ss = 0GoTo Line1End IfIf mm = 0 And ss = -1 And nn = 2 ThenMsgBox "放学咯!", vbSystemModalCommand1.Enabled = Falsenn = 3mm = 88: ss = 88End IfIf ss = -1 And mm > 0 Then mm = mm - 1: ss = 59If mm = 0 And hh > 0 Then hh = hh - 1: mm = 59 End Sub。

抖音同款课堂点名系统,PyQt5写起来很简单...

抖音同款课堂点名系统,PyQt5写起来很简单...

抖音同款课堂点名系统,PyQt5写起来很简单...刷抖音的时候发现一个老师在用的课堂点名系统。

用PyQt5实现了一下同款,导入学生姓名,测试了一下完美运行。

操作效果展示:完整源代码块还是放在了文章的最后面,有需要直接运行到文末获取下载方式就好了。

使用的时候准备好学生姓名的文件,使用导入数据的按钮直接导入就可以开始点名了。

新建一个文本文档,将姓名设置设置好,姓名文件示例如下。

使用系统库或者第三方库都比较常规,这里就不一一介绍了。

from PyQt5.QtWidgets import *from PyQt5.QtGui import *from PyQt5.QtCore import *from qdarkstyle import load_stylesheet_pyqt5import osimport sysimport timeimport random为了和UI界面的主线程分离开来,我们采用的还是QThread多线程的方式来实现随机点名模块的。

这样做的目的是为了防止主线程阻塞,下面是子线程的实现部分。

class WorkThread(QThread):trigger = pyqtSignal(str)finished = pyqtSignal(bool)def__init__(self, parent=None):super(WorkThread, self).__init__(parent)self.parent = parentself.working = Truedef__del__(self):self.working = Falseself.wait()def run(self):data_list = self.parent.data_listif len(data_list) >= 1:ran = random.randint(20, 40)print('遍历次数:', ran)for a in range(ran):name = random.choice(data_list)self.trigger.emit(name)print(name)time.sleep(0.6)self.finished.emit(True)else:self.trigger.emit('无数据')UI 界面的实现部分也比较常规,下面主要实现部分的代码块。

用VB编写点名系统

用VB编写点名系统

用VB编写点名系统张晓理工六班1.效果图运行前:运行以后:2.创建控件过程首新建工程里,将form的背景插入背景图片。

创建一个命令按钮,名称为Command1,调整其属性,Caption设置为“开始”二字;创建一个命令按钮,名称为Comman21,调整其属性,Caption设置为“退出”二字;创建标签一个,名称为label。

将其属性里的Alignment调整为2-center,目的是将标签里的字居中。

将front设置为楷体。

字体大小为17。

在创建一个按钮名称为timer1,调整其属性,设置间隔,即Timer1.Interval = 50定义名单跳转时间为50ms。

Timer1.Enabled = False。

3.代码Dim a() As StringDim i As IntegerPrivate Sub Command1_Click()If Command1.Caption = "开始" ThenCommand1.Caption = "暂停"Timer1.Enabled = TrueElseIf Command1.Caption = "暂停" ThenCommand1.Caption = "开始"Timer1.Enabled = FalseEnd IfEnd SubPrivate Sub Command2_Click()EndEnd SubPrivate Sub Form_Load()i = 0'定义名单跳转的时间间隔为10msTimer1.Interval = 100Timer1.Enabled = FalseCommand1.Caption = "开始"Label1.Alignment = 2 '字体居中Label1.Font = "微软雅黑" '字体为微软雅黑Label1.FontSize = 17 '设置字体大小'读取名单,注意:名单必须已经放在D盘的1.txt文件内 Open "D:\dianming.txt" For Input As #1Do Until EOF(1)i = i + 1ReDim Preserve a(1 To i) As StringLine Input #1, a(i) '按行读取,所以名单名字必须一行一个 LoopEnd SubPrivate Sub Timer1_Timer()Dim j As IntegerRandomize'i为名单的人数,Rnd为0-1之间的数,不包括0,1j = Int(1 + Rnd * i)Label1.Caption = a(j)End Sub。

VB制作随机点名程序源码!

VB制作随机点名程序源码!

VB制作幻灯片随机点名工具大家好,我是、灬尛坏坏"注:此程序适用于学校班级实用,此文是原创,转载请标明岀处,本次教程:这个在powerpoint里,完全和powerpoint结合起来,我简单写了一下,新建一个vb程序,在窗体上放一个label, 一个timer和一个按钮,timer 的interval 设置为1,Enable 设置为False。

源码(不解释,自己研究):Dim a(0 To 9) As StringPrivate Sub Command1_Click()Timer1.Enabled = Not Timer1.EnabledEnd SubPrivate Sub Form_Load()SetHotkey Me.hwnd, 1, 0, vbKeyHome,"Add"a(0)=" 张三"a(1)=" 李四"a(2)=" 王五"a(3)=" 刘六"a(4)=" 牛七"a(5)=" 马八”a(6)=" 杨九"a(7)=" 苟十"a(8)=" 朱----a(9)=" 吕十二”End SubPrivate Sub Form_Unload(Cancel As Integer)SetHotkey Me.hwnd, 1, 0, 0, "Del"End SubPrivate Sub Timer1_Timer()Dim i As Integeri = Int(Rnd * 10)Label1.Caption = a(i)Labell.Tag = iEnd Sub新建一个模块,写入以下代码Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVai hwnd As Long, ByVai nIndex As Long, ByVai dwNewLong As Long) As LongPrivate Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVai hwnd As Long, ByVai nIndex As Long) As LongPrivate Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVaiIpPrevWndFunc As Long, ByVai hwnd As Long, ByVai Msg As Long, ByVai wParam As Long, ByVai iParamAs Long) As LongPrivate Deciare Function RegisterHotKey Lib "user32" (ByVai hwnd As Long, ByVai id As Long, ByVai fskey_Modifiers As Long, ByVai vk As Long) As LongPrivate Deciare Function UnregisterHotKey Lib "user32" (ByVai hwnd As Long, ByVai id As Long)As LongPublic Deciare Function ShowWindow Lib "user32" (ByVai hwnd As Long, ByVai nCmdShow As Long) AsLongPublic Deciare Sub keybd_event Lib "user32" (ByVai bVk As Byte, ByVai Scan As Byte, ByVai dwFiagsAs Long, ByVai dwExtraInfo As Long)Public Deciare Function SendMessageLib "user32" Alias "SendMessageA" (ByVai hwnd As Long, ByVai wMsg As Long, ByVai wParam As Long, iParam As Any) As LongPublic Deciare Function SetForegroundWindow Lib "user32" (ByVai hwnd As Long) As LongConst SW_HIDE = 0Const SW_SHOW = 5Const WM_HOTKEY = & H312Const MOD_ALT = &H1Const MOD_CONTROL = &H2Const MOD_SHIFT = &H4Const GWL_WNDPROC = (-4)'窗口函数的地址Dim FormlsShowing As BooleanDim key_preWinProc As Long ' 用来保存窗口信息Dim key_IsWinAddress As Boolean ' 是否取得窗口信息的判断Function keyWndproc(ByVai hwnd As Long, ByVai Msg As Long, ByVai wParam As Long, ByVai iParamAs Long) As LongIf Msg = WM_HOTKEY ThenSelect Case wParam 'wParam 值就是 key_idHotKeyCase 1 '激活多个热键后,多个热键所对应的操作,大家在其他的程序中,只要修改此处就可以了FormlsShowing = Not FormlsShowingIf FormIsShowing ThenShowWindow hwnd, SW_HIDEElseShowWindow hwnd, SW_SHOW'SendMessage hwnd, & H32, 0, 0SetForegroundWindow hwndEnd If'Case 2'MsgBox "hide"'ShowWindow hwnd, SW_HIDEEnd SelectEnd If'将消息传送给指定的窗口keyWndproc = CallWindowProc(key_preWinProc, hwnd, Msg, wParam, IParam)End FunctionFunction SetHotkey(ByVal hwnd As Long, ByVal KeyId As Long, ByVal keyControlKey As Long, ByVal keyNormalKey As Long, ByVal Action As String)If key_IsWinAddress = False Then ' 判断是否需要取得窗口信息,如果重复取得,再最后恢复窗口时, 将会造成程序死掉'记录原来的window程序地址key_preWinProc = GetWindowLong(hwnd, GWL_WNDPROC)'用自定义程序代替原来的window程序SetWindowLong hwnd, GWL_WNDPROC, AddressOf keyWndprocEnd IfSelect Case ActionCase "Add"RegisterHotKey hwnd, KeyId, keyControlKey, keyNormalKey ' 向窗口注册系统热键key_IsWinAddress = True ' 不需要再取得窗口信息Case "Del"SetWindowLong hwnd, GWL_WNDPROC, key_preWinProc '恢复窗口信息UnregisterHotKey hwnd, KeyId ' 取消系统热键key_IsWinAddress = False ' 可以再次取得窗口信息End SelectEnd Function这样就成了,主要的思路是注册系统热欢迎您的下载,资料仅供参考!致力为企业和个人提供合同协议,策划案计划书,学习资料等等打造全网一站式需求。

VB中随机函数Rnd的应用-王敏

VB中随机函数Rnd的应用-王敏
六、教学过程
(一)情景创设,引入新课
[教师活动]展示实验要求:抛掷一枚骰子,观察出现的点数
[学生活动]六名学生分成三组.每组1人掷骰子,1人记录点数,每组分别测试10次
[师生互动]根据各组的实验数据得出结论,导出本节所学内容Rnd函数.
结论1:出现1点、2点……6点是基本事件
结论2:点数大于6点,是不可能事件
③思考现实生活中有哪些方面体现了随机性?
二、学习目标
(一)知识与能力
1、理解VB中Rnd函数的功能
2、掌握利用Rnd函数产生某范围内随机整数的方法
3、应用Rnd函数进行程序设计,解决实际问题
(二)过程与方法
1、通过实例演练,体验VB应用程序中代码编写、程序调试与保存的过程
2、通过VB程序的界面设计,强化各生在掌握知识的同时,也感受到在学习与生活中融入信息用互联网.
4、VB中随机函数Rnd是一个实用性很强的函函数求得随机整数解决实际问题.为此在教学中我采用任务驱动形式,注重培养学生的动手实践能力与逻辑思维分析能力.但在真正授课过程中,仍出现一些问题:
④使用Rnd函数之前,使用Randomize语句初始化随机数发生器,该发生器使用系统时钟的秒数作为随机数种子
2、通过实例体会Rnd函数的格式、功能与注意事项
[实例]在窗体中创建一个文本框和一个命令按钮.在命令按钮的Click事件中输入代码,生成随机数
代码如下:
Private Sub Command1_Click<>
无论使用任何编程语言,都有一个随机数,用来产生随机的种子,稍微对代码进行改良,就可以得到所想要的在一定范围之内的随机数.VB中随机函数Rnd是中等职业学校教学用书〔计算机技术专业〕《Visual Basic程序设计》〔第3版〕第三章第四节内容.
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

用vb制作随机点名器,提供代码及详细制作步骤
1.Form的Caption属性可命名为:课堂随机点名
2.在界面放入一个Listbox, 一个Label ,一个commandbotton,它们的属性不用改变。

3.右击表单Form,选择“查看代码”
4.输入下列代码:
Option Explicit
Dim flag As Boolean
Private Sub Command1_Click()
With Command1
If .Caption = "点名" Then
.Caption = "停止"
flag = False
test
Else
.Caption = "点名"
flag = True
End If
End With
End Sub
Function test()
Dim t
Do Until flag
Label1.Caption = List1.List(Int(Rnd * List1.ListCount)) t = Timer
Do Until Timer - t > 0.05
DoEvents
Loop
DoEvents
Loop
End Function
Private Sub Form_Load()
Dim arr, i As Integer
List1.Visible = False
Command1.Caption = "点名"
With Label1
.Caption = ""
.AutoSize = True
.ForeColor = vbRed
.FontSize = 24
.FontBold = True
End With
Open App.Path & "\123.txt" For Input As #1 (备注说明:在保存位置同一目录下新建一个123的文本文件,并把名单录入到文本中,一个名字一行。


Close #1
For i = 0 To UBound(arr)
If Len(arr(i)) > 0 Then List1.AddItem arr(i)
End Sub
运行界面如下:。

相关文档
最新文档