源程序:
Private Sub Command1_Click()
If Text1.Text <> "" Then Dim re As ADODB.Recordset
Dim con As New Connection
Dim st1 As String
Dim st2 As String
Dim st3 As String
Dim st4 As String
Dim st5 As String
Dim st6 As String
Dim st7 As String
Dim st8 As String
Dim sz1(1 To 10) As Single
Dim sz2(1 To 10) As Single
Dim sz3(1 To 4) As Single
Dim sz4(1 To 4) As Single
con.Open "dsn=shitiku"
For a = 1 To 40
sum1 = 0
sum2 = 0
sum3 = 0
sum4 = 0
For i = 1 To 10
Randomize
sz1(i) = Int(Rnd * 50) + 1
st1 = "select 分值*难度系数 as s1 from 选择题表 where 题型='选择'and 试题号=" & sz1(i)
Set re = con.Execute(st1)
sum1 = sum1 + re("s1")
Next i
For j = 1 To 10
Randomize
sz2(j) = Int(Rnd * 50) + 1
st2 = "select 分值*难度系数 as s2 from 填空题表 where题型='填空'and 试题号=" & sz2(j)
Set re = con.Execute(st2)
sum2 = sum2 + re("s2")
Next j
For k = 1 To 4
Randomize
sz3(k) = Int(Rnd * 25) + 1
st3 = "select 分值*难度系数 as s3 from 简答题表 where 题型='简答'and 试题号=" & sz3(k)
Set re = con.Execute(st3)
sum3 = sum3 + re("s3")
Next k
For l = 1 To 4
Randomize
sz4(l) = Int(Rnd * 25) + 1
st4 = "select 分值*难度系数 as s4 from 计算题表 where 题型='计算'and 试题号=" & sz4(l)
Set re = con.Execute(st4)
sum4 = sum4 + re("s4")
Next l
If (sum1 + sum2 + sum3 + sum4) / 100 = Val(Text1.Text) Then
End If
Next a
For i = 1 To 10
st5 = "select 内容 from 选择题表 where 试题号=" & sz1(i)
Set re = con.Execute(st5)
Form2.List1.AddItem re("内容")
Next i
For j = 1 To 10
st6 = "select 内容 from 填空题表 where 试题号=" & sz2(j)
Set re = con.Execute(st6)
Form2.List2.AddItem re("内容")
Next j
For k = 1 To 4
st7 = "select 内容 from 简答题表 where 试题号=" & sz3(k)
Set re = con.Execute(st7)
Form2.List3.AddItem re("内容")
Next k
For l = 1 To 4
st8 = "select 内容 from 计算题表 where 试题号=" & sz4(l)
Set re = con.Execute(st8)
Form2.List4.AddItem re("内容")
Next l
con.Close
Else: MsgBox "请输入难度系数"
End If
end sub
运行出错提示: 用户定义类型未定义
请帮帮忙
Private Sub Command1_Click()
If Text1.Text <> "" Then Dim re As ADODB.Recordset
Dim con As New Connection
Dim st1 As String
Dim st2 As String
Dim st3 As String
Dim st4 As String
Dim st5 As String
Dim st6 As String
Dim st7 As String
Dim st8 As String
Dim sz1(1 To 10) As Single
Dim sz2(1 To 10) As Single
Dim sz3(1 To 4) As Single
Dim sz4(1 To 4) As Single
con.Open "dsn=shitiku"
For a = 1 To 40
sum1 = 0
sum2 = 0
sum3 = 0
sum4 = 0
For i = 1 To 10
Randomize
sz1(i) = Int(Rnd * 50) + 1
st1 = "select 分值*难度系数 as s1 from 选择题表 where 题型='选择'and 试题号=" & sz1(i)
Set re = con.Execute(st1)
sum1 = sum1 + re("s1")
Next i
For j = 1 To 10
Randomize
sz2(j) = Int(Rnd * 50) + 1
st2 = "select 分值*难度系数 as s2 from 填空题表 where题型='填空'and 试题号=" & sz2(j)
Set re = con.Execute(st2)
sum2 = sum2 + re("s2")
Next j
For k = 1 To 4
Randomize
sz3(k) = Int(Rnd * 25) + 1
st3 = "select 分值*难度系数 as s3 from 简答题表 where 题型='简答'and 试题号=" & sz3(k)
Set re = con.Execute(st3)
sum3 = sum3 + re("s3")
Next k
For l = 1 To 4
Randomize
sz4(l) = Int(Rnd * 25) + 1
st4 = "select 分值*难度系数 as s4 from 计算题表 where 题型='计算'and 试题号=" & sz4(l)
Set re = con.Execute(st4)
sum4 = sum4 + re("s4")
Next l
If (sum1 + sum2 + sum3 + sum4) / 100 = Val(Text1.Text) Then
End If
Next a
For i = 1 To 10
st5 = "select 内容 from 选择题表 where 试题号=" & sz1(i)
Set re = con.Execute(st5)
Form2.List1.AddItem re("内容")
Next i
For j = 1 To 10
st6 = "select 内容 from 填空题表 where 试题号=" & sz2(j)
Set re = con.Execute(st6)
Form2.List2.AddItem re("内容")
Next j
For k = 1 To 4
st7 = "select 内容 from 简答题表 where 试题号=" & sz3(k)
Set re = con.Execute(st7)
Form2.List3.AddItem re("内容")
Next k
For l = 1 To 4
st8 = "select 内容 from 计算题表 where 试题号=" & sz4(l)
Set re = con.Execute(st8)
Form2.List4.AddItem re("内容")
Next l
con.Close
Else: MsgBox "请输入难度系数"
End If
end sub
运行出错提示: 用户定义类型未定义
请帮帮忙
解决方案 »
- 请问VB COM组件 javascript三者之间的关系是什么啊?
- 这世界真是美好啊........真的..........
- 懸賞:探討程序自動運行的有哪些方法 頂者有分
- MSHFlexGrid的问题
- access数据库打不开,请问有什么修复工具吗?急,急,急!!!( 在线等待)
- 为什么我的vb 没有资源文件编辑这项菜单,要怎么加载。
- ADO记录集如何导出到Excel表
- VB中如何添加ChkFile控件
- 程序运行起来后,其他不显示的窗体是否也已经被load了,如果没有,为什么可以给他们的属性付值?
- 寻找Win2000中文专业版序列号?
- 在程序运行时,右键单击ShockWave控件中的Flash会弹出菜单,任何去除这个菜单?
- Dim b As VBComponent语句编译错误
如果你的试题号如为数字型,不用这样如是字符型,要按以上的, 其他的st2,st3,st4都是这样格式Set re = con.Execute(st4)
sum4 = sum4 + re("s4")
Next l
If (sum1 + sum2 + sum3 + sum4) / 100 = Val(Text1.Text) Then
End If
Next are.close ‘是必需的///
......
下面的也要改过来
我那个没有引用ado
你的ADO控件都没有引用,当然不行了呀
再说你的SQL语句中的字段类型没有指定正确哟,呵呵
具体的代码,自己去写哟!!!!呵呵