当前位置:编程学习 > VB >>

求一个复杂的VB编程(课程设计用的)

小型测试系统的设计与实现要求能够随机生成20道数学计算题(要求有加,减,乘,除运算,规定操作数的个数),对用户结果进行判断,并能最终计算总成绩,要求用户在规定的时间内做完试题,超时自动终止并给出成绩。此题要求附带界面,要美观方便,易操作。做好后,发我邮箱。记得注明你的名字,方便我选择你的答案。
补充:那你给我做啊
答案:
VERSION 5.00
Begin VB.Form 自动生成题目
Caption = "自动生成题目"
ClientHeight = 4410
ClientLeft = 60
ClientTop = 435
ClientWidth = 6555
LinkTopic = "Form1"
ScaleHeight = 4410
ScaleWidth = 6555
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command2
Caption = "评分"
Height = 375
Left = 4920
TabIndex = 5
Top = 2160
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "生成题目"
Height = 375
Left = 4680
TabIndex = 4
Top = 120
Width = 1575
End
Begin VB.TextBox Text4
Height = 1575
Left = 2160
MultiLine = -1 'True
TabIndex = 3
Top = 2160
Width = 2055
End
Begin VB.TextBox Text3
Height = 1575
Left = 2160
MultiLine = -1 'True
TabIndex = 2
Top = 600
Width = 2055
End
Begin VB.TextBox Text2
Height = 270
Left = 3000
TabIndex = 1
Text = "0"
Top = 240
Width = 855
End
Begin VB.TextBox Text1
Height = 3135
Left = 240
MultiLine = -1 'True
TabIndex = 0
Top = 600
Width = 1935
End
Begin VB.Label Label1
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
BackStyle = 0 'Transparent
Caption = "请输入您想生成几位数计算的题目"
ForeColor = &H80000008&
Height = 180
Left = 240
TabIndex = 6
Top = 240
Width = 2700
End
End
Attribute VB_Name = "自动生成题目"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Ans() As String

Private Sub Command1_Click() '生成题目按钮
Text2 = Int(Val(Text2)) '文本框控件Text2
If Text2 <= 0 Then Exit Sub
Text1 = "" '文本框控件Text1
Text3 = "" '文本框控件Text3
Dim I(), k(), f(3), M As String, j, x, y As Integer
f(0) = "+" 'f存放运算符号
f(1) = "-"
f(2) = "*"
f(3) = "/"

ReDim k(1 To Text2), I(1 To Text2), Ans(1 To 20) 'k存放计算数字,i存放运算符号 As Integer

For x = 1 To 20
For j = 1 To Text2 '初始化
k(j) = 0
If j < Text2 Then I(j) = 0
Next j

For j = 1 To Text2 'j是计算数字的个数
Do While CInt(k(j)) = 0
k(j) = Int(Rnd() * 100)
Loop
Next j

M = ""
For j = 1 To Text2
I(j) = f(Round(Rnd() * 3, 0))
Text1 = Text1 & k(j)
M = M & k(j)
If j < Text2 Then Text1 = Text1 & I(j)
If j < Text2 Then M = M & I(j)
Next j
Ans(x) = Round(Result(M), 1) '把答案放进数组里,方便评分的时候和学生的答案做对比
Text1 = Text1 & vbCrLf 'Text1显示的是题目
Text3 = Text3 & Ans(x) & " " 'Text3显示的是答案
Next x
Text3 = Trim(Text3)
End Sub

Function Result(ByVal x As String) '调用EXCEL来计算字符串,调试的时候请先引用Microsoft Excel object library
Dim myobj As Object
Set myobj = CreateObject("excel.sheet")
Set myobj = myobj.Application.ActiveWorkbook.ActiveSheet
myobj.Range("a1").Formula = "= " & x '
Result = myobj.Range("a1").Value
If Err.Number > 0 Then MsgBox Err.Description
Set myobj = Nothing
End Function

Private Sub Command2_Click() '评分按钮
Dim f() As String, I As Integer, Score As Single
f = Split(Text4, " ")
For I = 0 To UBound(f)
If CSng(Val(f(I))) = Ans(I + 1) Then Score = Score + 5 '对比答案,如果正确就加5分,20道题刚好100分//因为f(i)是字符串,所以做对比的时候要把字符串转成数值
Debug.Print f(I), Ans(I + 1)
Next I
MsgBox "分数是" & Score
End Sub
这也叫复杂么?
没留email啊
至于美观  你得自己找图片装了

上一个:高分求VB.NET制作一个图片浏览器 详细
下一个:谁有VB材料的,是理论部分的?

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,