当前位置:新励学网 > 秒知问答 > 谁能找到用vb编写得考试系统

谁能找到用vb编写得考试系统

发表时间:2024-07-12 03:17:36 来源:网友投稿

form1:

PrivateSubCommand1_Click()

Dimcls2AsClass2

Setcls2=NewClass2

cls2.getstr2(CStr(Text1.Text))

'MsgBoxCStr(cls2.a0)

Dima(10)AsString

a(0)=cls2.a0'kaohao

a(1)=cls2.a1'name

a(2)=cls2.a2'sex

a(3)=cls2.a3'ximing

a(4)=cls2.a4'grade

a(5)=cls2.a5'class

Form2.Label1.Caption=当前用户:&a(1)&&考号:&a(0)&&系名:&a(3)&&年级:&a(4)&&班级:&a(5)

Form2.Show

'Form3.Show

EndSub

PrivateSubCommand2_Click()

End

EndSub

=============================================================

form2:

Dima(10)AsString

PrivateSubCommand1_Click()

MsgBox你确定交卷吗?

EndSub

PrivateSubForm_Load()

Text1.Width=Form2.Width

Text1.Height=Form2.Height

Text1.Top=0

Text1.Left=0

'//////////////////////////////////////////导入数据

Text1.Text=单项选择题&vbNewLine

Text1.Text=Text1.Text&&vbNewLine

DimiAsLong

DimclsAsClass1

Setcls=NewClass1

Fori=0To19

cls.getstr

a(0)=cls.a0'id

a(1)=cls.a1'subject

a(2)=cls.a2'a

a(3)=cls.a3'b

a(4)=cls.a4'c

a(5)=cls.a5'd

a(6)=cls.a6'answer

Text1.Text=Text1.Text&CStr(i+1)&.&vbNewLine

Text1.Text=Text1.Text&a(1)&vbNewLine

Text1.Text=Text1.Text&A:&a(2)&

Text1.Text=Text1.Text&B:&a(3)&

Text1.Text=Text1.Text&C:&a(4)&

Text1.Text=Text1.Text&D:&a(5)&&vbNewLine

Text1.Text=Text1.Text&&vbNewLine

Nexti

'//////////////////////////////////////////

EndSub

PrivateSubForm_Resize()

Text1.Width=Form2.Width

Text1.Height=Form2.Height*0.85

Text1.Top=Form2.Height*0.15

Text1.Left=0

Label1.Top=0

Label1.Left=0

Label1.Width=Form2.Width

'Label1.Height=Form2.Height*0.2*0.1

Label1.AutoSize=True

DimiAsInteger

Fori=0To9

Form2.Combo1(i).Top=Form2.Height*0.2*0.2

Form2.Combo1(i).Left=Form2.Width*i/10

Form2.Combo1(i).Width=Form2.Width/10

'Form2.Combo1(i).Height=Form2.Height*0.2*0.4

Nexti

Fori=10To19

Form2.Combo1(i).Top=Form2.Height*0.2*0.4

Form2.Combo1(i).Left=Form2.Width*(i-10)/10

Form2.Combo1(i).Width=Form2.Width/10

'Form2.Combo1(i).Height=Form2.Height*0.2*0.4

Nexti

Command1.Top=0

Command1.Left=Form2.Width-Command1.Width

EndSub

=============================================================

class1.module

Dima(10)AsString

PublicFunctiongetstr()AsString

DimconnAsADODB.Connection

Setconn=NewADODB.Connection

DimrsAsADODB.Recordset

Setrs=NewADODB.Recordset

conn.ConnectionString=DSN=kaoshi

conn.ConnectionTimeout=30

conn.Open

DimqueryAsString

'======================================

query=select*fromtiku

rs.Openquery,conn,adOpenStatic,adLockOptimistic

DimiAsLong

rs.MoveFirst

i=0

DoWhile(Notrs.EOF)

i=i+1

rs.MoveNext

Loop

rs.Close

'MsgBoxCStr(i)

DimcountAsLong

Math.Randomize

count=i*Math.Rnd

If(1<=countAndcount<=i)Then

Else

MsgBoxERROR:&CStr(count)

count=1

EndIf

'MsgBoxCStr(count)

'=======================================

query=select*fromtikuwhereid=&CStr(count-1)

rs.Openquery,conn,adOpenStatic,adLockOptimistic

a(0)=CStr(rs!id)

a(1)=rs!subject

a(2)=rs!a

a(3)=rs!b

a(4)=rs!c

a(5)=rs!d

a(6)=rs!answer

'a(7)=rs!catalog

'a(8)=rs!nandu

'a(9)=rs!fenxi

rs.Close

conn.Close

EndFunction

PublicPropertyGeta0()AsVariant

a0=a(0)

EndProperty

PublicPropertyLeta0(ByValvNewValueAsVariant)

EndProperty

PublicPropertyGeta1()AsVariant

a1=a(1)

EndProperty

PublicPropertyLeta1(ByValvNewValueAsVariant)

EndProperty

PublicPropertyGeta2()AsVariant

a2=a(2)

EndProperty

PublicPropertyLeta2(ByValvNewValueAsVariant)

EndProperty

PublicPropertyGeta3()AsVariant

a3=a(3)

EndProperty

PublicPropertyLeta3(ByValvNewValueAsVariant)

EndProperty

PublicPropertyGeta4()AsVariant

a4=a(4)

EndProperty

PublicPropertyLeta4(ByValvNewValueAsVariant)

EndProperty

PublicPropertyGeta5()AsVariant

a5=a(5)

EndProperty

PublicPropertyLeta5(ByValvNewValueAsVariant)

EndProperty

PublicPropertyGeta6()AsVariant

a6=a(6)

EndProperty

PublicPropertyLeta6(ByValvNewValueAsVariant)

EndProperty

============================================================

class2.module

Dima(10)AsString

PublicFunctiongetstr2(strAsString)AsString

DimconnAsADODB.Connection

Setconn=NewADODB.Connection

DimrsAsADODB.Recordset

Setrs=NewADODB.Recordset

conn.ConnectionString=DSN=kaoshi

conn.ConnectionTimeout=30

conn.Open

DimqueryAsString

Dimtmp%

tmp=0

'=============判断

query=selectkaohaofromstudent

rs.Openquery,conn,adOpenStatic,adLockOptimistic

rs.MoveFirst

DoWhile(Notrs.EOF)

If(rs!kaohao=str)Then

MsgBox考号正确!!

tmp=1

ExitDo

Else

EndIf

rs.MoveNext

Loop

If(tmp=0)Then

MsgBox考号不正确!!

End

EndIf

rs.Close

'=============

query=select*fromstudentwherekaohao='&str&'

rs.Openquery,conn,adOpenStatic,adLockOptimistic

a(0)=rs!kaohao

a(1)=rs!Name

a(2)=rs!sex

a(3)=rs!ximing

a(4)=rs!grade

a(5)=rs!Class

rs.Close

conn.Close

EndFunction

PublicPropertyGeta0()AsVariant

a0=a(0)

EndProperty

PublicPropertyLeta0(ByValvNewValueAsVariant)

EndProperty

PublicPropertyGeta1()AsVariant

a1=a(1)

EndProperty

PublicPropertyLeta1(ByValvNewValueAsVariant)

EndProperty

PublicPropertyGeta2()AsVariant

a2=a(2)

EndProperty

PublicPropertyLeta2(ByValvNewValueAsVariant)

EndProperty

PublicPropertyGeta3()AsVariant

a3=a(3)

EndProperty

PublicPropertyLeta3(ByValvNewValueAsVariant)

EndProperty

PublicPropertyGeta4()AsVariant

a4=a(4)

EndProperty

PublicPropertyLeta4(ByValvNewValueAsVariant)

EndProperty

PublicPropertyGeta5()AsVariant

a5=a(5)

EndProperty

PublicPropertyLeta5(ByValvNewValueAsVariant)

EndProperty

免责声明:本站发布的教育资讯(图片、视频和文字)以本站原创、转载和分享为主,文章观点不代表本网站立场。

如果本文侵犯了您的权益,请联系底部站长邮箱进行举报反馈,一经查实,我们将在第一时间处理,感谢您对本站的关注!