问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

VB语言编程

发布网友 发布时间:2022-04-26 15:21

我来回答

3个回答

热心网友 时间:2022-05-01 19:20

Option Explicit

Private Sub Command1_Click()
Dim a As Integer
Dim b As Integer
Dim c As Integer
Static r As Integer
Static ct As Integer
Static n As Integer

If Command1.Caption = "开始" Or Command1.Caption = "下一题" Then
a = Int(Rnd() * 90) + 10
b = Int(Rnd() * 90) + 10
c = Int(Rnd() * 4)
Select Case c
Case 0
Label2.Caption = a & " + " & b & " = ?"
r = a + b
Case 1
If a < b Then
r = a
a = b
b = r
End If
Label2.Caption = a & " - " & b & " = ?"
r = a - b
Case 2
a = Int(Rnd() * 100) + 1
b = Int(Rnd() * 100) + 1

If a < b Then
r = a
a = b
b = r
End If
r = a \ b
If r = 0 Then r = 1
a = b * r
a = r
Label2.Caption = a & " * " & b & " = ?"
r = a * b
Case 3
a = Int(Rnd() * 100) + 1
b = Int(Rnd() * 100) + 1
If a < b Then
r = a
a = b
b = r
End If
r = a \ b
If r = 0 Then r = 1
a = b * r
Label2.Caption = a & " / " & b & " = ?"
r = a \ b
End Select
Command1.Caption = "提交答案"
Label3.Caption = ""
Text1.Text = ""
Else
If Text1.Text = "" Then
MsgBox "请输入答案", vbCritical
Exit Sub
End If
Label2.Caption = Left(Label2.Caption, Len(Label2.Caption) - 1) & Text1.Text
n = n + 1

If Val(Text1.Text) = r Then
Label3.Caption = "√"
Label3.ForeColor = vbBlue
ct = ct + 1
Else
Label3.Caption = "×" & "(正确答案:" & r & ")"
Label3.ForeColor = vbRed
End If
List1.AddItem Label2.Caption & Label3.Caption
Command1.Caption = "下一题"
Label1.Caption = "正确率" & Format(ct / n, "00.0%")
End If
End Sub

Private Sub Form_Load()
Command1.Caption = "开始"
Label1.Caption = "正确率:0%"
Label2.Caption = "点开始按钮答题"
Label3.Caption = ""
Text1.Text = ""
Randomize Timer
End Sub

不明白的加百度HI给你发代码

热心网友 时间:2022-05-01 20:38

保存到1.frm,运行。。。代码里 设置题目总数 那行可以修改为需要的数字,希望能来得及,完。

VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 6150
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 6150
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "开始"
Height = 375
Left = 120
TabIndex = 4
Top = 2580
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "提交"
Enabled = 0 'False
Height = 375
Left = 1080
TabIndex = 3
Top = 840
Width = 1095
End
Begin VB.ListBox List1
Height = 2760
Left = 3120
TabIndex = 2
Top = 120
Width = 2955
End
Begin VB.TextBox Text1
Height = 315
Left = 1740
TabIndex = 1
Top = 180
Width = 1155
End
Begin VB.Label Label1
Height = 315
Left = 180
TabIndex = 0
Top = 180
Width = 1275
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim A As Integer, B As Integer, C As Integer, NumDo As Integer, DoRight As Integer
Const NumAll As Integer = 10 '设置题目总数

Private Sub RandomNum() '生成算式
Randomize
C = Rnd() * 4
C = 3
If C = 0 Then
A = Int(Rnd() * 90) + 10
B = Int(Rnd() * 90) + 10
ElseIf C = 1 Then
A = 0
B = 99
Do While A < B
A = Int(Rnd() * 90) + 10
B = Int(Rnd() * 90) + 10
Loop
ElseIf C = 2 Then '不知道两位数乘法还是结果是两位数,按第二种吧
A = Int(Rnd() * 10)
B = Int(Rnd() * 10)
ElseIf C = 3 Then '同上,按九九乘法表+0+10的,结果可以整除的
B = Int(Rnd() * 10) + 1
A = B * Int(Rnd() * 10)
End If
If C = 0 Then '显示的,符号自己改
Label1.Caption = Trim(Str(NumDo)) & ". " & Trim(Str(A)) & " + " & Trim(Str(B)) & "="
ElseIf C = 1 Then
Label1.Caption = Trim(Str(NumDo)) & ". " & Trim(Str(A)) & " - " & Trim(Str(B)) & "="
ElseIf C = 2 Then
Label1.Caption = Trim(Str(NumDo)) & ". " & Trim(Str(A)) & " * " & Trim(Str(B)) & "="
ElseIf C = 3 Then
Label1.Caption = Trim(Str(NumDo)) & ". " & Trim(Str(A)) & " / " & Trim(Str(B)) & "="
End If
End Sub

Private Sub JiSuan() '计算得分
MsgBox "总分是" & Format(100 * (DoRight / NumAll), "00.0") & vbNewLine & "准确率" & Format((DoRight / NumAll) * 100, "00.00") & "%"
End Sub

Private Sub Command1_Click()
Dim D As Integer
If C = 0 Then
D = A + B
ElseIf C = 1 Then
D = A - B
ElseIf C = 2 Then
D = A * B
ElseIf C = 3 Then
D = A / B
End If
If Text1.Text = D Then
List1.AddItem Label1.Caption & D & " √"
DoRight = DoRight + 1
Else
List1.AddItem Label1.Caption & D & " ×"
End If
If NumDo < NumAll Then
NumDo = NumDo + 1
Call RandomNum
Else
Call JiSuan
Command1.Enabled = False
Command2.Caption = "重新开始"
End If
End Sub

Private Sub Command2_Click()
If Command2.Caption = "开始" Then
Command2.Caption = "重新开始"
Command1.Enabled = True
List1.Clear
NumDo = 1
DoRight = 0
Call RandomNum
Else
Command2.Caption = "开始"
Command1.Enabled = False
NumDo = 1
DoRight = 0
End If
End Sub

热心网友 时间:2022-05-01 22:12

希望对楼主有用:

Dim sum As Single
Private Sub Command1_Click()
Randomize
x = Int((101) * Rnd) (定义两位数!)
y = Int((101) * Rnd)
Select Case Int((4) * Rnd + 1)
Case 1
Text1.Text = x & "+" & y
sum = x + y
Case 2
Text1.Text = x & "-" & y
sum = x - y
Case 3
Text1.Text = x & "*" & y
sum = x * y
Case 4
Text1.Text = x & "/" & y
sum = x / y
End Select
End Sub

Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 100
Label1.Caption = "欢迎使用算术练习题"
Label1.AutoSize = True
Label1.Move 0, 0
Command1.Caption = "出题"
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If sum = Val(Text2.Text) Then
List1.AddItem Text1.Text & "=" & Text2.Text & " √"
Else
List1.AddItem Text1.Text & "=" & Text2.Text & " X"
End If
End If
End Sub

Private Sub Timer1_Timer()
Label1.Left = Label1.Left + 20
If Label1.Left + Label1.Width >= Me.ScaleWidth Then Label1.Left = 0
End Sub
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
苹果电脑电池充不进电苹果电脑充不进去电是怎么回事 苹果电脑不充电没反应苹果电脑充电指示灯不亮充不了电怎么办 狗狗更加忠诚护家、善解人意,养一只宠物陪伴自己,泰迪能长多大... 描写泰迪狗的外形和特点的句子 国外留学有用吗 花钱出国留学有用吗 !这叫什么号 百万医疗赔付后是否可以续保 前一年理赔过医疗险还能续保吗? 医疗住院险理赔后还能购买吗? 放烟花热闹的场面 想要一些有新年氛围的图片, 剪纸啊、烟花、年夜饭之类的? 礼花是什么意思 办宴席的时候常常会准备“礼花剪纸”,主要是用来做什么呢? 拼多多店铺达到什么级别才可以上视频图? 抖音直接用拼多多衣服图片做视频侵权吗 一斤肉放锅里开水煮多久能煮熟啊 猪肉一般煮多久能熟? 猪肉煮多长时间熟,猪肉片煮多久才熟 猪肉煮多久才熟 猪肉一般煮多久才煮的好 猪肉要煮多久才能熟透? 猪肉煮多久全熟啊? 猪肉煮多长时间才熟 白酒标准号GB/T10781.2是什么意思 白酒标准号GB/T10781.1-2006代表什么意思?- 问一问 VB程序设计语言是一种 (A)高级语言(B)汇编语言 (C)机器语言 (D)数据库语言 白酒的标准号是GB/T10781是什么意思 VB语言程序设计问题 学习VB语言程序设计难吗 春联,灯笼,窗花,烟花爆竹,是什么类的 VB语言程序设计的翻译是:什么意思 VB语言程序设计P169中sum给定power VB语言编程的格式及代码。 英语的放烟花或放鞭炮,贴对联,春节晚会,分别怎么说? csgo里面有哪些冷门枪皮? 企业微信营销推广方案应该怎么写? 苹果手机怎样取消更新系统 北京限号怎么查询? 苹果怎么取消系统更新,不想更新,如果实在要更新,会不会手机反应变慢?? 限号怎么查 北京汽车限号查询 北京车辆限号查询 如何提高网站关键词排行? 北京汽车限号怎么查 北京汽车的限号是怎么规定的 亚马逊如何提高关键词排名 微信不扫码直接输入密码支付 如何提升百度关键词搜索的排名呢 搜索引擎如何提高排名