【VB开源代码栏目提醒】:网学会员--在 VB开源代码编辑为广大网友搜集整理了:VB程序设计第三版实验H答案 - 编程语言绩等信息,祝愿广大网友取得需要的信息,参考学习。
VB程序设计第三版实验H答案全 1 Private Sub Command1_Click Open c:score For Output As 1 Print 1 051023 王海涛 66 Print 1 052498 周文英 88 Print 1 050992 陈建东 77 Open c:score1 For Output As 2 Write 2 051023 王海涛 66 Write 2 052498 周文英 88 Write 2 050992 陈建东 77 Close i1 ShellNOTEPAD.exe c:score vbNormalNoFocus i2 ShellNOTEPAD.exe c:score1 vbNormalNoFocus End Sub Private Sub Command2_Click Dim no As String name As String s As Integer Open c:score For Input As 1 Do While Not EOF1 Line Input 1 linedata List1.AddItem linedata Loop Open c:score1 For Input As 2 Do While Not EOF2 Input 2 no name s List2.AddItem no name s Loop Close End Sub 2 Private Sub Command1_Click Dim fib0 To 9 i Open c:fb.dat For Output As 1 For i 0 To 9 If i 0 Or i 1 Then fibi i Else fibi fibi - 1 fibi - 2 End If Print 1 Fib i fibi Next i Close 1 i ShellNOTEPAD.exe c:fb.dat vbNormalNoFocus End Sub Private Sub Command2_Click Dim st n sum Open c:fb.dat For Input As 1 Do While Not EOF1 Input 1 st n sum sum n List1.AddItem st n Loop Close 1 List1.AddItem 合计 sum List1.AddItem 平均 sum / 10 End Sub 3 4 Private Type studtype no As String 4 name As String 6 mark As Single End Type Dim student As studtype stud1 To 5 As studtype t As studtype Private Sub Command1_Click Open d:score.dat For Random As 1 Len Lenstudent With student .no 0001 .name 星期一 .mark 66 End With Put 1 1 student With student .no 0002 .name 星期二 .mark 99 End With Put 1 2 student With student .no 0003 .name 星期三 .mark 88 End With Put 1 3 student With student .no 0004 .name 星期四 .mark 55 End With Put 1 4 student With student .no 0005 .name 星期五 .mark 77 End With Put 1 5 student Close 1 End Sub Private Sub Command2_Click Open d:score.dat For Random As 1 Len Lenstudent For i 1 To 5 Get 1 i student Print student.no student.name student.mark studi student Next i Close 1 For i 1 To 5 For j i 1 To 5 If studi.mark studj.mark Then t studi: studi studj: studj t Next Next i Open d:random1.dat For Random As 2 Len Lenstudent For i 1 To 5 Put 2 i studi Next i Close 1 End Sub Private Sub Command3_Click Open d:random1.dat For Random As 1 Len Lenstudent For i 1 To 5 Get 1 i studi Print studi.no studi.name studi.mark Next i Close 1 End Sub 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 ValText1.Text .name Text2.Text .sex IIfOption1.Value 1 0 .mark ValText3.Text End With Open c:score For Random As 1 Len Lenstd record LOF1 / Lenstd 1 Label1.Caption record Put 1 record std Close 1 End Sub Private Sub Command2_Click Open c:score For Random As 1 Len Lenstd record ValText4.Text Get 1 record std Text1.Text std.no Text2.Text std.name If std.sex 1 Then Option1.Value True Else Option2.Value True End If Text3.Text std.mark record LOF1 / Lenstd Close 1 End Sub Private Sub Command3_Click With std .no ValText1.Text .name Text2.Text .sex IIfOption1.Value 1 0 .mark ValText3.Text End With Open c:score For Random As 1 Len Lenstd record ValText4.Text Put 1 record std Close 1 End Sub Private Sub Command4_Click Open c:score For Random As 1 Len Lenstd record 1 Get 1 record std Text1.Text std.no Text2.Text std.name If std.sex 1 Then Option1.Value True Else Option2.Value True End If Text3.Text std.mark record LOF1 / Lenstd Close 1 Text4.Text 1 End Sub Private Sub Command5_Click Open c:score For Random As 1 Len Lenstd record ValText4.Text - 1 If ValText4.Text ValLabel1.Caption Then MsgBox 超出记录范围 2 vbExclamation 警告: Close Else Get 1 record std Text1.Text std.no Text2.Text std.name If std.sex 1 Then Option1.Value True Else Option2.Value True End If Text3.Text std.mark record LOF1 / Lenstd Close 1 Text4.Text ValText4.Text 1 End If End Sub Private Sub Command7_Click Open c:score For Random As 1 Len Lenstd record ValLabel1.Caption Get 1 record std Text1.Text std.no Text2.Text std.name If std.sex 1 Then Option1.Value True Else Option2.Value True End If Text3.Text std.mark record LOF1 / Lenstd Close 1 Text4.Text record End Sub Private Sub Form_Load Open c:score For Random As 1 Len Lenstd Label1.Caption LOF1 / Lenstd Close 1 End Sub 6 Private Type studtype no As Integer name As String 6 mark As Integer End Type Dim std As studtype Dim record As Integer Private Sub Command1_Click With std .no ValText1.Text .name Text2.Text .mark ValText3.Text End With Open c:score1 For Random As 1 Len Lenstd record LOF1 / Lenstd 1 Put 1 record std Close 1 Text1.Text Text2.Text Text3.Text Text1.SetFocus End Sub Private Sub Command2_Click Dim sum count As Integer Open c:score1 For Random As 1 Len Lenstd For i 1 To record Get 1 i std sum sum std.mark count count 1 List1.AddItem std.no std.name std.mark Next i List1.AddItem 总分 sum List1.AddItem 平均成绩 sum / count Close 1 End Sub 7 Private Sub Command1_Click Dim inputdata1 inputdata2 inputdata3 As String 1 Dim v byt1 As Byte byt2 As Byte flen1 As Long flen2 As Long fnum fnum3 As Integer Text1.Text : Text2.Text : Text3.Text CommonDialog1.ShowOpen fname1 CommonDialog1.FileName CommonDialog2.ShowOpen fname2 CommonDialog2.FileName Open fname1 For Binary As 1 Open fname2 For Binary As 2 Do While Not EOF1 inputdata1 Input1 1 Text1.Text Text1.Text inputdata1 Loop Do While Not EOF2 inputdata2 Input1 2 Text2.Text Text2.Text inputdata2 Loop fnum3 FreeFile Open c:hb.txt For Binary As fnum3 Put fnum3 1 byt1 Put fnum3 flen1 1 byt2 Do While Not EOFfnum3 inputdata3 Input1 fnum3 Text3.Text Text3.Text inputdata3 Loop If Dirfname1 Then fnum FreeFile Open fname1 For Binary As fnum flen1 LOFfnum ReDim byt1flen1 - 1 Get fnum 1 byt1 Close fnum End If If Dirfname2 Then fnum FreeFile Open fname2 For Binary As fnum flen2 LOFfnum ReDim byt2flen2 - 1 Get fnum 1 byt2 Close fnum End If