主题:一个出数学加减题的程序【新】
孙瑞
[专家分:590] 发布于 2007-07-16 22:24:00
修正了程序的乘除错误!基本无错!
恳请高手指正代码!
谢谢!
[b]欢迎查错!![/b]
[b]sunruiyeyipeng@163.com[/b]
[url=http://sunrui.123ye.com]我的网站[/url]
[fly]Help Me![/fly]
最后更新于:2007-09-07 22:02:00
回复列表 (共23个回复)
21 楼
孙瑞 [专家分:590] 发布于 2007-09-07 22:05:00
在我的努力下,在网友们的支持下,我已经成功修正了错误,发布了最新版!
欢迎指正错误,提出建议和好的代码!谢谢!
22 楼
bcahzvip [专家分:6040] 发布于 2007-09-08 08:00:00
想加上语言?
23 楼
孙瑞 [专家分:590] 发布于 2010-04-11 00:45:00
[quote]'代码冗长,格式不规范.多改进!
Dim daan(100) As Long
Dim shuzi1&, shuzi2 As Long '定义变量方式要注意
Dim sdp As Long
Dim scro1&, scro2 As Long
Dim pldid As Long
Dim does(100) As Long
Dim kaishi As Boolean
Dim chen As Integer
Dim user As String
Private Sub Combo1_Click()
chen = 10 ^ (Combo1.ListIndex + 1) '这里帮你改了下
End Sub
Private Sub Command1_Click()
Dim wr1$, wr2 As String
Dim textfor As String
Dim Lth As Integer
Lth = Len(Str(chen)) - 1
Combo1.Enabled = False
kaishi = True
List1.Clear
For chu! = 1 To 25
'*准备题目数据
'取数据
shuzi1 = Int(Rnd(6) * chen)
shuzi2 = Int(Rnd(6) * chen)
wr1 = Trim(Str(shuzi1))
wr2 = Trim(Str(shuzi2))
textfor = Space(Lth - Len(wr1)) & wr1 & "+" & wr2 & Space(Lth - Len(wr2)) & "="
daan(chu) = shuzi1 + shuzi2
List1.AddItem textfor
'删除数据,准备再用
Next chu
For chu = 26 To 50
shuzi1 = Int(Rnd(6) * chen)
shuzi2 = Int(Rnd(6) * chen)
wr1 = Trim(Str(shuzi1))
wr2 = Trim(Str(shuzi2))
If shuzi1 < shuzi2 Then
textfor = Space(Lth - Len(wr2)) & wr2 & "-" & wr1 & Space(Lth - Len(wr1)) & "="
'timu(chu) = textfor
Else
textfor = Space(Lth - Len(wr1)) & wr1 & "-" & wr2 & Space(Lth - Len(wr2)) & "="
'make it useless
End If
daan(chu) = IIf(shuzi1 < shuzi2, shuzi2 - shuzi1, shuzi1 - shuzi2)
List1.AddItem textfor
shuzi1 = 0
shuzi2 = 0
textfor = ""
Next chu
'*************************
'乘法
For chu = 51 To 75
shuzi1 = Int(Rnd(6) * chen) + 1 '为什么不直接用这句????
shuzi2 = Int(Rnd(6) * chen) + 1
wr1 = Trim(Str(shuzi1))
wr2 = Trim(Str(shuzi2))
textfor = Space(Lth - Len(wr2)) & wr2 & "×" & wr1 & Space(Lth - Len(wr1)) & "="
List1.AddItem textfor
daan(chu) = shuzi2 * shuzi1
shuzi1 = 0
shuzi2 = 0
textfor = ""
Next chu
'除法
For chu = 76 To 100
'↓↓↓↓↓↓↓↓↓↓↓完全重复的一段代码↓↓↓↓↓↓↓↓↓
shuzi1 = Int(Rnd(6) * chen) + 1
shuzi2 = Int(Rnd(6) * chen) + 1
If shuzi1 > shuzi2 And (Int(shuzi1 / shuzi2) = shuzi1 / shuzi2) Then
wr1 = Trim(Str(shuzi1))
wr2 = Trim(Str(shuzi2))
textfor = Space(Lth - Len(wr1)) & wr1 & "÷" & wr2 & Space(Lth - Len(wr2)) & "="
daan(chu) = shuzi1 / shuzi2 '改错 这就是你除法错的地方
List1.AddItem textfor
Else
'↑↑↑↑↑↑↑↑↑↑↑完全重复的一段代码↑↑↑↑↑↑↑↑
wem:
shuzi1 = Int(Rnd(6) * chen) + 1
shuzi2 = Int(Rnd(6) * chen) + 1
If shuzi1 < shuzi2 Or Int(shuzi1 / shuzi2) <> shuzi1 / shuzi2 Then GoTo wem
'''''''''''''''''''''''''''''''
wr1 = Trim(Str(shuzi1))
wr2 = Trim(Str(shuzi2))
textfor = Space(Lth - Len(wr1)) & wr1 & "÷" & wr2 & Space(Lth - Len(wr2)) & "="
daan(chu) = shuzi1 / shuzi2
List1.AddItem textfor
shuzi1 = 0
shuzi2 = 0
textfor = ""
End If ''''''''
Next chu
List1.ListIndex = 0
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
user = InputBox("请输入您的姓名:", "输入框", "利多")
chen = 10
kaishi = False
Randomize
Label1.Caption = "请点击“出题”键出题!"
End Sub
Private Sub List1_Click()
'***检查做过了没有******
If does(List1.ListIndex + 1) <> 1 Then
'****************************
Label1.Caption = List1.Text
sdp = List1.ListIndex + 1
Text1.SetFocus
Else
Label1.Caption = "这道题你已经做过了!!"
End If
End Sub[/quote]
daan(chu) = shuzi1 / shuzi2 '改错 这就是你除法错的地方
什么错了,怎么错了?请指教!谢谢。
我来回复