教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 法律文档 >

vb程序设计教程课后答案与实验题答案(第三版)(10)

来源:网络收集 时间:2026-08-29
导读: Private Sub Command2_Click() Dim st$, n%, sum% Open \Do While Not EOF(1) Input #1, st, n sum = sum + n List1.AddItem st stud(i).name; stud(i).mark Next i Close #1 End Sub H.5 Private Type studtype n

Private Sub Command2_Click() Dim st$, n%, sum%

Open \Do While Not EOF(1) Input #1, st, n sum = sum + n

List1.AddItem st & \Loop Close #1

List1.AddItem \合计:\List1.AddItem \平均:\End Sub

H.3

H.4

Private Type studtype

no As String * 4 name As String * 6 mark As Single End Type

Dim student As studtype, stud(1 To 5) As studtype, t As studtype

Private Sub Command1_Click()

Open \With student .no = \

.name = \星期一\ .mark = 66 End With

Put #1, 1, student With student .no = \

.name = \星期二\ .mark = 99 End With

Put #1, 2, student With student .no = \

.name = \星期三\ .mark = 88 End With

Put #1, 3, student With student .no = \

.name = \星期四\ .mark = 55 End With

Put #1, 4, student With student .no = \

.name = \星期五\ .mark = 77 End With

Put #1, 5, student Close #1 End Sub

Private Sub Command2_Click()

Open \For i = 1 To 5 Get #1, i, student

Print student.no, student.name, student.mark stud(i) = student Next i Close #1 For i = 1 To 5 For j = i + 1 To 5

If stud(i).mark > stud(j).mark Then t = stud(i): stud(i) = stud(j): stud(j) = t Next Next i

Open \For i = 1 To 5 Put #2, i, stud(i) Next i Close #1 End Sub

Private Sub Command3_Click()

Open \For i = 1 To 5 Get #1, i, stud(i)

Print stud(i).no; stud(i).name; stud(i).mark Next i Close #1

End Sub

H.5

Private Type studtype no As Integer

name As String * 20 sex As String * 1 mark As Single End Type

Dim std As studtype Dim record As Integer

Private Sub Command1_Click() With std

.no = Val(Text1.Text) .name = Text2.Text

.sex = IIf(Option1.Value, \.mark = Val(Text3.Text) End With

Open \record = LOF(1) / Len(std) + 1 Label1.Caption = record Put #1, record, std Close #1 End Sub

Private Sub Command2_Click()

Open \record = Val(Text4.Text) Get #1, record, std Text1.Text = std.no Text2.Text = std.name If std.sex = \Option1.Value = True Else

Option2.Value = True End If

Text3.Text = std.mark

record = LOF(1) / Len(std) Close #1 End Sub

Private Sub Command3_Click()

With std

.no = Val(Text1.Text) .name = Text2.Text

.sex = IIf(Option1.Value, \.mark = Val(Text3.Text) End With

Open \record = Val(Text4.Text) Put #1, record, std Close #1 End Sub

Private Sub Command4_Click()

Open \record = 1

Get #1, record, std Text1.Text = std.no Text2.Text = std.name If std.sex = \Option1.Value = True Else

Option2.Value = True End If

Text3.Text = std.mark

record = LOF(1) / Len(std) Close #1

Text4.Text = 1 End Sub

Private Sub Command5_Click()

Open \record = Val(Text4.Text) - 1 If Val(Text4.Text) <= 1 Then

MsgBox \超出记录范围\警告\Else

Get #1, record, std Text1.Text = std.no Text2.Text = std.name If std.sex = \Option1.Value = True Else

Option2.Value = True End If

Text3.Text = std.mark

record = LOF(1) / Len(std) Close #1

Text4.Text = Val(Text4.Text) - 1 End If End Sub

Private Sub Command6_Click()

Open \record = Val(Text4.Text) + 1

If record > Val(Label1.Caption) Then

MsgBox \超出记录范围\警告\Else

Get #1, record, std Text1.Text = std.no Text2.Text = std.name If std.sex = \Option1.Value = True Else

Option2.Value = True End If

Text3.Text = std.mark

record = LOF(1) / Len(std) Close #1

Text4.Text = Val(Text4.Text) + 1 End If End Sub

Private Sub Command7_Click()

Open \record = Val(Label1.Caption) Get #1, record, std Text1.Text = std.no Text2.Text = std.name If std.sex = \Option1.Value = True Else

Option2.Value = True End If

Text3.Text = std.mark

record = LOF(1) / Len(std) Close #1

Text4.Text = record End Sub

…… 此处隐藏:253字,全部文档内容请下载后查看。喜欢就下载吧 ……
vb程序设计教程课后答案与实验题答案(第三版)(10).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/435676.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)