VB脚本编写的小题库程序
来源:互联网 发布:世界网络发展史 编辑:程序博客网 时间:2024/04/29 07:28
一、程序运行截图
二、主要思想
就是把Excel也当成一个数据库,只不过这个数据库只支持文本。程序可以改变和增加Excel里面的题目内容,题库也会相应增大,注意总题数也要改成和实际题目数目相应的数字。
本程序的Excel结构如下:
三、脚本内容
Option Explicit
Public currentNum, questionNum, totalNum As Integer
Public optionValue, correctAnswer As String
Private Sub CommandButtonAnswer_Click()
correctAnswer = Worksheets("Sheet1").Cells(questionNum, 6)
If OptionButtonAnswerA Then
optionValue = "A"
ElseIf OptionButtonB Then
optionValue = "B"
ElseIf OptionButtonC Then
optionValue = "C"
ElseIf OptionButtonD Then
optionValue = "D"
End If
If (StrComp(optionValue, correctAnswer) = 0) Then
LabelHint.Caption = "回答正确"
Else
LabelHint.Caption = "回答错误,正确答案是" + correctAnswer
End If
End Sub
Private Sub CommandButtonNext_Click()
If CheckBoxRnd Then
currentNum = Int((totalNum * Rnd) + 1)
questionNum = currentNum + 1
Else
currentNum = (currentNum + 1) Mod totalNum
If currentNum <> 0 Then
questionNum = currentNum + 1
Else
questionNum = totalNum + 1
End If
End If
LabelTitle.Caption = Worksheets("Sheet1").Cells(questionNum, 1)
OptionButtonAnswerA.Caption = "A." + Worksheets("Sheet1").Cells(questionNum, 2)
OptionButtonB.Caption = "B." + Worksheets("Sheet1").Cells(questionNum, 3)
OptionButtonC.Caption = "C." + Worksheets("Sheet1").Cells(questionNum, 4)
OptionButtonD.Caption = "D." + Worksheets("Sheet1").Cells(questionNum, 5)
LabelHint.Caption = ""
OptionButtonAnswerA = False
OptionButtonB = False
OptionButtonC = False
OptionButtonD = False
End Sub
Private Sub UserForm_Activate()
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_Initialize()
currentNum = 1
questionNum = currentNum + 1
totalNum = CInt(Worksheets("Sheet1").Cells(2, 7))
optionValue = ""
correctAnswer = ""
LabelHint = ""
LabelTitle.Caption = Worksheets("Sheet1").Cells(questionNum, 1)
OptionButtonAnswerA.Caption = "A." + Worksheets("Sheet1").Cells(questionNum, 2)
OptionButtonB.Caption = "B." + Worksheets("Sheet1").Cells(questionNum, 3)
OptionButtonC.Caption = "C." + Worksheets("Sheet1").Cells(questionNum, 4)
OptionButtonD.Caption = "D." + Worksheets("Sheet1").Cells(questionNum, 5)
End Sub
附:脚本下载地址 http://download.csdn.net/detail/ciel_arc/9428962
- VB脚本编写的小题库程序
- shell脚本编写小程序
- VB小软件编写的问题
- 用VB编写基于控制台的程序
- 小程序编写的美女
- 编写我的小程序
- 通过编写Python小程序来统计测试脚本的关键字分析 20160328
- VB编写摇奖程序
- Shell脚本编写的几个小知识点
- VB代码 VB小程序
- 用VB做的一个小程序
- VB txt 转换 excel 的小程序
- Matlab 编写的求汉诺塔的小程序
- 用VB编写的向数据库添加记录的程序
- vb编写彩票投注程序
- 用VB编写抽奖程序
- 密码破解小程序的编写
- 用C#编写的计算器小程序
- 云计算的基础概念
- 单例
- LightOJ 1028 1028 - Trailing Zeroes (I) (求因子个数)
- 2016
- POJ 3070 矩阵的幂
- VB脚本编写的小题库程序
- ES6学习——模块化:Module Loader API
- 用Instruments 简单分析内存
- 文章标题
- 将博客搬至CSDN
- 第四章表达式
- 查看linux系统版本命令
- Mvc中日期格式化、下拉列表DropDownListFor、单选框RadioButtonFor使用方式
- hdu 5623 KK's Number