首页  VB程序设计教程(第3版)课后实验答案

 VB程序设计教程(第3版)课后实验答案

举报
开通vip

 VB程序设计教程(第3版)课后实验答案 VB程序设计教程(第3版)课后实验答案 End SubA(1 Private Sub Form_Load() Private Sub Command1_Click() Caption = "装入窗体" Label3 = Text1 End Sub Picture = LoadPicture(App.Path + "\n_016.bmp") A(2 Print "装入图" Private Sub Form_Load() Timer1.Interval = 0 End Sub End Sub Privat...

 VB程序设计教程(第3版)课后实验答案
 VB程序设计教程(第3版)课后实验答案 End SubA(1 Private Sub Form_Load() Private Sub Command1_Click() Caption = "装入窗体" Label3 = Text1 End Sub Picture = LoadPicture(App.Path + "\n_016.bmp") A(2 Print "装入图" Private Sub Form_Load() Timer1.Interval = 0 End Sub End Sub Private Sub Form_Resize() ' 该事件的作用Private Sub Command1_Click() '自动 窗体始终与图一样大 Timer1.Interval = 200 End Sub 'Caption = "窗体大小不变" Private Sub Command2_Click() '手动 'Form1.Width = 260 * 16 ' 260是 Timer1.Interval = 0 Call MyMove Tongji-2.bmp图的宽度,象素单位 End Sub Private Sub Timer1_Timer() 'Form1.Height = 260 * 16 + 200 ' 260是图的 Call MyMove End Sub 高度,象素单位,200是窗体的标 快递公司问题件快递公司问题件货款处理关于圆的周长面积重点题型关于解方程组的题及答案关于南海问题 栏高度 Sub MyMove() Label1.Move Label1.Left - 50 End Sub If Label1.Left < 0 Then Label1.Left = A(5 Form1.Width End Sub Sub Command1_Click() Text1.FontName = "隶 关于书的成语关于读书的排比句社区图书漂流公约怎么写关于读书的小报汉书pdf " A(3 Private Sub Form_Click() Text1.FontSize = 25 Text1 = Val(Text1) + 1 End Sub End Sub Sub Command2_Click() Private Sub Form_Load() Text2.Text = Text1.SelText Text1 = 0 Text2.FontName = Text1.FontName End Sub Text2.FontSize = Text1.FontSize End Sub A(4 B(1 Private Sub Form_Click() Private Sub Command1_Click() Caption = "单击窗体,改变图片" Text2 = Format(5 / 9 * (Val(Text1) - 32), "0.00") Picture = LoadPicture(App.Path + End Sub "\n_015.bmp") Private Sub Command2_Click() Text1 = Format(9 / 5 * Val(Text2) + 32, "0.00") Print "欢迎使用VB" End Sub End Sub 或 Private Sub Form_DblClick() Cls Private Sub Command1_Click() Caption = "双击窗体,卸去图片" Dim f!, c! ' 声明两个变量 Picture = LoadPicture("") ' f = Val(Text1) c = 5 / 9 * (f - 32) B(3 Text2 = Format(c, "0.00") ' 保留两位小数 Private Sub Command1_Click() End Sub n = Int(Log(2) / Log(1.008) + 1) Private Sub Command2_Click() Label1 = n & "年后人数超过26亿" Dim ff!, cc! ' 声明两个变End Sub 量 B(4 cc = Val(Text2) Private Sub Command1_Click() ff = 9 / 5 * cc + 32 Dim x, dx, cd x = Text1.Text Text1 = Format(ff, "0.00") ' 保留两位小数 dx = UCase(x) End Sub cd = Len(x) Print "大写字母为:"; dx B(2 Private Sub Command1_Click() Print "字符串长度为:"; cd Label2 = Format(Val(Text1) * Val(Text1) * 3.14, "0.00") End Sub End Sub B(5 Private Sub Command2_Click() Label3 = Format(Val(Text1) * 3.14 * 2, "0.00") Private Sub Command1_Click() End Sub Text1 = Int(Rnd * 900 + 100) Private Sub Text1_LostFocus() End Sub If Not IsNumeric(Text1.Text) Then Private Sub Command2_Click() Dim x%, x1%, x2%, x3% MsgBox "输入有非数字字符,请重新输入 x = Val(Text1) ", , "警告" x1 = x Mod 10 ' 分离出 Text1.Text = "" 的个位数 Text1.SetFocus End If x2 = (x Mod 100) \ 10 ' 分离出的End Sub 或 十位数 Private Sub Command1_Click() x3 = x \ 100 ' 分离出的 Label2 = Format(Val(Text1) * Val(Text1) * 3.14, "0.00") 百位数 End Sub Private Sub Command2_Click() Label1 = x1 * 100 + x2 * 10 + x3 Label3 = Format(Val(Text1) * 3.14 * 2, "0.00") End Sub End Sub B(6 Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Private Sub Form_Click() If Not IsNumeric(Text1.Text) Then Label1 = Left(Text1, 11) Text1.Text = "" Label2 = Mid(Text1, 12, 6) End If Label3 = Right(Text1, 5) End If End Sub End Sub B(7 y = 0.8 * x Private Sub Command1_Click() Else Print y = 0.7 * x For i = 1 To 5 End If Print Tab(15 - i * 2); String(2 * i - 1, "?"); Print y End Sub Spc(18 - 4 * (i - 1)); String(2 * i - 1, "?") C(2 Next i End Sub Private Sub Form_Click() Private Sub Command2_Click() Dim x!, y! Cls x = Val(InputBox("输入上网时间")) End Sub If x < 10 Then 进一步要求: y = 30 Private Sub Command1_Click() ElseIf x < 50 Then Print y = 30 + 2.5 * (x - 10) For i = 1 To 5 Else y = 30 + 2.5 * 40 + 2 * (x - 50) Print Tab(15 - i * 2); String(2 * i - 1, "?"); End If If y > 150 Then String(10 - (2 * i - 1), "?"); String(2 * i - 1, "?") y = 150 Next i End If End Sub Print y Private Sub Command2_Click() End Sub Cls C(3 End Sub Private Sub Command1_Click() B(8 Dim x!, y!, z! Private Sub Form_Click() x = InputBox("input x") y = InputBox("input y") x = Val(InputBox("输入一正实数", "计算", 0)) z = InputBox("input z") pf = Format(x * x, "0.000") Print " x y z" pfg = Format(Sqr(x), "0.000") Print " 排序前"; x; " "; y; " "; z lf = Format(x * x * x, "0.000") lfg = Format(x ^ (1 / 3), "0.000") If x < y Then t = x: x = y: y = t If x < z Then t = x: x = z: z = t Print "平方为:"; pf; Space(5); "平方根为:"; pfg; If y < z Then t = y: y = z: z = t Space(5); "立方为:"; lf; Space(5); "立方根为:"; lfg Print " 排序后" & x & " " & y & " " & z End Sub End Sub Private Sub Command2_Click() C(1 Dim x!, y!, z! Private Sub Form_Click() x = InputBox("input x") Dim x!, y! y = InputBox("input y") x = Val(InputBox("输入x的值")) z = InputBox("input z") If x < 1000 Then Print " x y z" y = x Print " 排序前"; x; " "; y; " "; z ElseIf x < 2000 Then y = 0.9 * x If x < y Then t = x: x = y: y = t ElseIf x < 3000 Then If y < z Then t = y: y = z: z = t Text2 = "" If x < y Then Text2.SetFocus t = x: x = y: y = t Else End If x = n / 2 - m End If Label2 = y Label3 = m - y Print " 排序后" & x & " " & y & " " & z End If End Sub End If End Sub C(4 C(6 Dim a(3) As Integer Private Sub Command1_Click() Private Sub Command1_Click() Picture1.Cls Dim a!, b!, c!, x1!, x2!, de! For i = 0 To 2 a = Text1 a(i) = Int(Rnd * 100 + 200) b = Text2 Picture1.Print a(i) c = Text3 Next i de = b * b - 4 * a * c End Sub t = 2 * a Private Sub Command2_Click() If de = 0 Then Picture2.Cls Text4 = Format(-b / t, "0.00") Dim z As Integer Text5 = Format(-b / t, "0.00") For i = 0 To 1 ElseIf de > 0 Then If a(i) > a(i + 1) Then Text4 = Format((-b + Sqr(de)) / t, "0.00") z = a(i + 1) Text5 = Format((-b - Sqr(de)) / t, "0.00") a(i + 1) = a(i) Else a(i) = z Text4 = Format(-b / t, "0.00") & "+" & End If Format(Sqr(Abs(de)) / t, "0.00") & "i" Next i Text5 = Format(-b / t, "0.00") & "-" & Picture2.Print a(0) Format(Sqr(Abs(de)) / t, "0.00") & "i" Picture2.Print a(1) End If Picture2.Print a(2) End Sub End Sub Private Sub Command2_Click() Text1 = "" C(5 Text2 = "" Private Sub Text2_LostFocus() Text3 = "" Dim m%, n%, y% Text4 = "" m = Val(Text1) Text5 = "" n = Val(Text2) End Sub If n Mod 2 <> 0 Then C(7 MsgBox ("脚数必定为偶数") Private Sub Text3_LostFocus() Text2 = "" Select Case Trim(Text3) Text2.SetFocus Case "+" Else Text4 = Val(Text1) + Val(Text2) y = n / 2 - m Case "-" If y < 0 Then Text4 = Val(Text1) - Val(Text2) Case "*" MsgBox ("脚数必须?2倍的头数,请重新 Text4 = Val(Text1) * Val(Text2) Case "/" 输入") If Val(Text2) = 0 Then Private Sub Form_Click() MsgBox "分母为零,重新输入" For i = 1 To 9 Text2 = "" Print Tab(10 - i); String(2 * i - 1, Trim(Str(i))) Text2.SetFocus Next i Else End Sub Text4 = Val(Text1) / Val(Text2) D(2 End If End Select Private Sub Form_Click() End Sub For i = 1 To 10 Step 1 Print Tab(i); String((20 - 2 * i), Chr(64 + i)) C(8 Next i Private Sub Text1_LostFocus() End Sub Select Case Trim(Text1) D(3 Case 1 Text2 = "Monday" Private Sub Command1_Click() Case 2 Dim s!, t!, i& Text2 = "Tuesday" s = 1 Case 3 t = 1 Text2 = "Wednesday" For i = 1 To 100000 Case 4 t = t + i Text2 = "Thursday" s = s + 1 / t Case 5 If 1 / t < 0.00001 Then Exit For Text2 = "Friday" Next i Case 6 Print "For结构"; s, i; "项" Text2 = "Saturday" Case 7 End Sub Text2 = "Sunday" D(4 Case Is > 7, Is < 1 Private Sub Command1_Click() MsgBox "数字为1~7,重新输入" Dim n&, pi#, i& Text1 = "" n = InputBox("输入n值") Text1.SetFocus End Select pi = 2 End Sub For i = 1 To n pi = pi * (2 * i) / (2 * i - 1) * (2 * i) / (2 * i + 1) 或者 Next i Private Sub Text1_LostFocus() Print "当n=" & n & "时,pi="; pi If Text1 > 7 Or Text1 < 1 Then End Sub MsgBox "数字为1~7,重新输入" D(5 Text1 = "" Text1.SetFocus Private Sub Form_Click() Else Dim s!, t!, i!, a%, n% Text2 = Choose(Text1, "Monday", "Tuesday", a = Int(Rnd * 9 + 1) "Wednesday", "Thursday", "Friday", "Saturday", n = Int(Rnd * 6 + 5) "Sunday") t = 0: s = 0 End If Print "a="; a, "n="; n End Sub For i = 1 To n t = t * 10 + a D(1 s = s + t Print t; End Sub Next i D(9 Print Print "s="; s Private Sub Command4_Click() End Sub Picture1.Cls Picture1.Print "x课安排在 "; "y课安排在 "; "zD(6 Private Sub Command1_Click() 课安排在 " Dim s As Integer s = 0 Picture1.Print "" For i = 1 To 9 For z = 5 To 6 For j = 0 To 9 For x = 1 To z - 2 For k = 0 To 9 For Y = x + 1 To z - 1 s = i * 100 + j * 10 + k X1 = Choose(Weekday(x), "周一", "周二", "周三", If s = i ^ 3 + j ^ 3 + k ^ 3 Then Print s "周四", "周五", "周六", "周日") End If Next k Y1 = Choose(Weekday(Y), "周一", "周二", "周三", Next j Next i "周四", "周五", "周六", "周日") End Sub Private Sub Command3_Click() z1 = Choose(Weekday(z), "周一", "周二", "周三", formd6.Hide main.Show "周四", "周五", "周六", "周日") End Sub Picture1.Print " "; X1; " "; Y1; " "; D(7 z1 Private Sub Command1_Click() Next Y Dim a!, x0!, x1! Next x a = 27 Next z x0 = 2 End Sub i = 0 Do E(1 i = i + 1 x1 = 2 * x0 / 3 + a / (3 * x0 * x0) Private Sub Form_Click() If Abs(x1 - x0) < 0.00001 Then Exit Do Dim a(1 To 10) As Integer x0 = x1 For i = 1 To 10 Loop a(i) = Int(Rnd * 71 + 30) Print x1, i Print a(i); " "; End Sub Next i Max = a(1) D(8 Min = a(1) Private Sub Command1_Click() Avg = a(1) s = 0 For i = 2 To 10 x0 = 0.01 If a(i) > Max Then Max = a(i) For i = 1 To 30 If a(i) < Min Then Min = a(i) s = s + x0 Avg = Avg + a(i) x0 = x0 * 2 Next i Next i Avg = Avg / 10 Print s Print Print "Max="; Max; " Min="; Min; " Avg="; End Sub Avg E(4 End Sub Private Sub Command1_Click() E(2 Picture1.Cls Private Sub Form_Click() Dim d%(1 To 10) Dim a For i3 = 1 To 10 a = Array(56, 78, 98, 88, 76, 78) Randomize For i = 0 To 5 d(i3) = Int(Rnd * 91 + 10) Next i3 Print String(a(i) \ 5, "?"); a(i) For i = 1 To 10 Print For j = 1 To 10 - i Next i If d(j) < d(j + 1) Then End Sub t = d(j): d(j) = d(j + 1): d(j + 1) = t End If E(3 Next j Dim a%(19) Next i Private Sub Command1_Click() For i = 1 To 10: Picture1.Print d(i); Picture1.Cls If i Mod 5 = 0 Then Picture1.Print For i = 0 To 19 Next i a(i) = Int(Rnd * 101) End Sub Picture1.Print a(i); " "; E(5 If (i + 1) Mod 4 = 0 Then Picture1.Print Next i Dim a%(3, 3), b%(3, 3) End Sub Private Sub Form_Load() For i = 0 To 3 Private Sub Command2_Click() For j = 0 To 3 Picture2.Cls a(i, j) = Int(Rnd * 36 + 35) Dim s(5 To 9) b(i, j) = Int(Rnd * 41 + 100) For i = 0 To 19 Next j k = a(i) \ 10 Next i Select Case k End Sub Case 0 To 5 Private Sub Command1_Click() s(5) = s(5) + 1 Picture1.Cls For i = 0 To 3 Case 9 To 10 '90,100分的人数 For j = 0 To i s(9) = s(9) + 1 Picture1.Print a(i, j); " "; Next j Case 6 To 8 ' 存放其他三个 Picture1.Print Next i 分数段的下标有规律,根据K获得 End Sub s(k) = s(k) + 1 Private Sub Command2_Click() End Select Picture2.Cls Next i For i = 0 To 3 For i = 5 To 9 For j = i To 3 Picture2.Print Tab(j * 6); b(i, j); If s(i) <> 0 Then Picture2.Print "s("; i; ")的 Next j Picture2.Print 人数有 "; Format(s(i), "0"); "个" Next i Next i End Sub List1.AddItem "硬件技术基础" Private Sub Command3_Click() Picture3.Cls List1.AddItem "软件技术技术基础" sa = 0 For i = 0 To 3 End Sub sa = sa + a(i, i) Next i Private Sub List1_Click() sb = 0 If List2.ListCount >= 5 Then For i = 0 To 3 MsgBox ("超过5门课程,不能再选") sb = sb + b(i, 3 - i) Next i Exit Sub Else Picture3.Print "A数组主对角线元素和为:"; sa List2.AddItem List1.Text List1.RemoveItem List1.ListIndex Picture3.Print "B数组副对角线元素和为:"; sb End If End Sub End Sub E(6 E(8 Private Sub Form_Click() Sub Combo1_KeyPress(KeyAscii As Integer) Select Case KeyAscii n = InputBox("输入n值") Case 48 To 57, 13 ReDim a6%(n + 1, n + 1) Case Else a6(0, 0) = 1: a6(1, 1) = 1: a6(1, 0) = 1 KeyAscii = 0 For i = 2 To n + 1 End Select For j = 2 To i If KeyAscii = 13 Then a6(i, j) = a6(i - 1, j - 1) + a6(i - 1, j) Combo1.AddItem Combo1.Text Picture1.Print a6(i, j); ""; Combo1.Text = "" Next j End If Picture1.Print End Sub Next End Sub Private Sub Command1_Click() Dim min%, max% E(7 min = Val(Combo1.List(0)) Private Sub Form_Load() max = Val(Combo1.List(0)) List1.Clear imin = 0 imax = 0 List1.AddItem "大学计算机基础" For i = 1 To Combo1.ListCount - 1 If Val(Combo1.List(i)) > max Then List1.AddItem "C/C++程序设计" imax = i max = Combo1.List(i) List1.AddItem "VB程序设计" ElseIf Val(Combo1.List(i)) < min Then imin = i List1.AddItem "Web程序设计" min = Combo1.List(i) End If List1.AddItem "多媒体技术与应用" Next i t = Combo1.List(0) List1.AddItem "数据库技术与应用" Combo1.List(0) = Combo1.List(imin) Combo1.List(imin) = t List1.AddItem "网络技术与应用" t = Combo1.List(Combo1.ListCount - 1) Combo1.List(Combo1.ListCount - 1) = Combo1.List(imax) End If Combo1.List(imax) = t Next j End Sub Next i Picture1.Cls E(9 Picture1.Print "工号 姓名 Private Sub Form_Click() For i = 0 To Screen.FontCount - 1 工资" If Asc(Left(Screen.Fonts(i), 1)) < 0 Then Picture1.Print Screen.Fonts(i) For i = 0 To n - 1 Picture2.FontName = Screen.Fonts(i) Picture1.Print a(i).number, a(i).name, a(i).salary Picture2.Print "商丘师范学院" Print End If Next i Next i End Sub End Sub F(1 E(10 Private Sub Form_Click() Private Type clerk Dim a(1 To 10), amin, i% number As String * 3 For i = 1 To 10 name As String * 5 a(i) = -Int(Rnd * 101 + 300) salary As Integer Print a(i); End Type Next i Dim a(0 To 4) As clerk, n% Call s(a(), amin) Print Private Sub Command1_Click() Print "min="; amin If n >= 5 Then End Sub Sub s(b(), min) MsgBox ("输入人数超过数组声明的个数") Dim i% Else min = b(LBound(b)) With a(n) For i = LBound(b) + 1 To UBound(b) .number = Text1 If b(i) < min Then min = b(i) .name = Text2 Next i .salary = Text3 End Sub Picture1.Print a(n).number, a(n).name, a(n).salary F(2 Print End With Private Sub Command1_Click() n = n + 1 Dim mm%, nn% Text1 = "" mm = Val(Text1) Text2 = "" nn = Val(Text2) Text3 = "" Picture1.Print mm; Tab(6); nn; Tab(12); gcd(mm, End If nn) End Sub End Sub Function gcd%(ByVal m%, ByVal n%) Private Sub Command2_Click() If m < n Then t = m: m = n: n = t Dim t As clerk, i%, j% r = m Mod n For i = 0 To n - 1 Do While (r <> 0) For j = i To n - 1 m = n: n = r: r = m Mod n If a(i).salary < a(j + 1).salary Then Loop t = a(i): a(i) = a(j + 1): a(j + 1) = t gcd = n End Function Function IsH(ss As String) As Boolean Dim i%, Ls% F(3 IsH = True Dim x! ss = Trim(ss)Private Sub Command1_Click() Ls = Len(ss) For i = 1 To Ls \ 2 Print "调用 标准 excel标准偏差excel标准偏差函数exl标准差函数国标检验抽样标准表免费下载红头文件格式标准下载 函数 excel方差函数excelsd函数已知函数     2 f x m x mx m      2 1 4 2拉格朗日函数pdf函数公式下载 Sin的结果"; Sin(x) If Mid(ss, i, 1) <> Mid(ss, Ls + 1 - i, 1) End Sub Then Private Sub Command2_Click() IsH = False Exit Function Print "调用自定义函数 MySin的结果"; End If MySin(x) Next i End Sub End Function Function MySin(x!) As Double F(5 Dim i%, t!, s! t = x Function prime(ByVal m As Integer) As Boolean s = t prime = True i = 1 Dim i% Do While Abs(t) > 0.00001 For i = 2 To m - 1 t = -1 * t * x * x / ((i + 1) * (i + 2)) If (m Mod i) = 0 Then prime = False: Exit Function s = s + t '注意冒号和exit的范围 i = i + 2 Loop Next i MySin = s End Function End Function Private Sub Command3_Click() Private Sub Command1_Click() n = 0 x = InputBox("输入要计算正弦函数的角度值x") For i = 6 To 100 Step 2 x = x * 3.14 / 180 For j = 3 To i \ 2 End Sub If prime(j) Then If prime(i - j) Then F(4 List1.AddItem i & " =" & j & " +" & i - j Private Sub Text1_KeyPress(KeyAscii As Integer) n = n + 1 If KeyAscii = 13 Then End If If Not IsNumeric(Text1) Then End If Next j MsgBox "输入非数字串,重新输入" Next i Text1.Text = "" Picture1.Print " 6和100之间共有"; n; "对素数和" Text1.SetFocus Else End Sub If IsH(Text1) Then F(6 Picture1.Print Text1; " ? " Dim a%() Else Private Sub Form_Click() Picture1.Print Text1 Print "1000以内的完数为:" End If Text1 = "" For i = 1 To 1000 End If If IsWs(i) Then End If Print i; "=1"; End Sub For j = 1 To UBound(a) Print "+"; a(j); Dim maxw$ Next j maxlen Text1 & " ", maxw Print Text2 = maxw End If End Sub Next i Sub maxlen(s$, maxw$) End Sub Dim word$ Function IsWs(m) As Boolean maxw = "" Dim s% Do While s <> "" s = 0 i = InStr(s, " ") For i = 1 To m \ 2 word = Left(s, i - 1) If m Mod i = 0 Then If Len(word) > Len(maxw) Then maxw = ReDim Preserve a(j) word a(j) = i s = Mid(s, i + 1) j = j + 1 Loop s = s + i End Sub End If G(1 Next i If m = s Then IsWs = True Private Sub Command1_Click() End Function List1.Clear List1.AddItem Combo1 If Option1 Then List1.AddItem "Pentium II" F(7 If Option2 Then List1.AddItem "Pentium I" Private Sub DeleStr(s1 As String, ByVal s2 As If Option3 Then List1.AddItem "Celeron" String) List1.AddItem Text1 Dim i% If Check1 Then List1.AddItem "声卡" ls2 = Len(s2) i = InStr(s1, s2) If Check2 Then List1.AddItem "Modem" Do While i > 0 If Check3 Then List1.AddItem "网络适配器" s1 = Left(s1, i - 1) + Mid(s1, i + ls2) ' 在s1中End Sub 去除s2子串 Private Sub Text1_LostFocus() i = InStr(s1, s2) st = UCase(Trim(Text1)) Loop le = Len(st) End Sub If Not IsNumeric(Left(st, le - 2)) Or Right(st, 2) <> Private Sub Command1_Click() "MB" Then ' 调用DeleStr子过程 MsgBox "有不合法字符~" Dim ss1 As String Text1 = "" ss1 = Text1 Text1.SetFocus Call DeleStr(ss1, Text2) End If Text3 = ss1 End Sub End Sub G(2 Private Sub Command2_Click() Private Sub Check1_Click() Picture1.Font.Bold = Not Picture1.Font.Bold End Sub End Sub F(8 Private Sub Check2_Click() Private Sub Command1_Click() Picture1.Font.Italic = Not Picture1.Font.Bold End Sub t = InputBox("输入倒计时分钟数") Private Sub Command1_Click() t = t * 60 Picture1.Cls ProgressBar1.Min = 0 If Option1 Then ProgressBar1.Max = t Picture1.Print Sin(Val(Text1)) ProgressBar1.Value = t ElseIf Option2 Then End Sub Picture1.Print Exp(Val(Text1)) ElseIf Option3 Then Private Sub Command2_Click() Picture1.Print Sqr(Val(Text1)) Timer1.Interval = 1000 End If ProgressBar1.Visible = True End Sub End Sub Private Sub return_Click(Index As Integer) Private Sub Timer1_Timer() Form6.Show Dim m%, s% Unload Form2 t = t - 1 End Sub ProgressBar1.Value = t m = t \ 60 G(3 s = t Mod 60 Private Sub HScroll1_Change() Label1 = m & "分" & s & "秒" Text1 = VScroll1.Value Text2 = HScroll1.Value If t = 0 Then Text3 = HScroll2.Value MsgBox "时间到~" Text4 = Format(Val(Text1) * (Text3 / 100) * (Text2 / 12), "0.00") Timer1.Interval = 0 Text5 = Format(Val(Text4) + Val(Text1), "0.00") ProgressBar1.Visible = False End Sub End If End Sub Private Sub HScroll2_Change() G(5 Text1 = VScroll1.Value Text2 = HScroll1.Value Private Sub Command1_Click() Text3 = HScroll2.Value CommonDialog1.ShowColor Text4 = Format(Val(Text1) * (Text3 / 100) * Label1.ForeColor = CommonDialog1.Color (Text2 / 12), "0.00") End Sub Text5 = Format(Val(Text4) + Val(Text1), "0.00") End Sub Private Sub Command2_Click() CommonDialog1.ShowOpen Private Sub VScroll1_Change() i = Shell("C:\WINDOWS\NOTEPAD.exe " + Text1 = VScroll1.Value CommonDialog1.FileName, vbNormalFocus) Text2 = HScroll1.Value End Sub Text3 = HScroll2.Value G(6 Text4 = Format(Val(Text1) * (Text3 / 100) * (Text2 / 12), "0.00") rivate Sub bold_Click() Text5 = Format(Val(Text4) + Val(Text1), "0.00") Text1.FontBold = Not Text1.FontBold End Sub bold.Checked = Not bold.Checked End Sub G(4 Dim t As Single Private Sub del_Click() Private Sub Command1_Click() Text1 = "" End Sub End Private Sub end_Click() End Sub End End Sub Private Sub 删除最大值_Click() Private Sub font12_Click() max = List1.List(0) Text1.FontSize = 12 For i = 1 To List1.ListCount - 1 End Sub If max < List1.List(i) Then max = List1.List(i): j = i Private Sub font16_Click() Next i Text1.FontSize = 16 List1.RemoveItem jEnd Sub End Sub Private Sub Form_Load() Private Sub 删除最小值_Click() bold.Checked = False italic.Checked = False min = List1.List(0) End Sub For i = 1 To List1.ListCount - 1 If min > List1.List(i) Then min = List1.List(i): j Private Sub italic_Click() = i Text1.FontItalic = Not Text1.FontItalic Next i italic.Checked = Not italic.Checked List1.RemoveItem j End Sub End Sub Private Sub Text1_MouseDown(Button As Integer, Private Sub 随机产生_Click() Shift As Integer, X As Single, Y As Single) If Button = 2 Then PopupMenu menu2 Randomize End Sub For i = 0 To 9 List1.List(i) = Int(Rnd * 30 + 70) G(7 Next i Private Sub Command1_Click() End Sub CommonDialog1.ShowColor Label1.ForeColor = CommonDialog1.Color Private Sub 添加数据_Click() End Sub List1.AddItem Int(Rnd * 30 + 70) Private Sub Command2_Click() End Sub CommonDialog1.ShowOpen i = Shell("C:\WINDOWS\NOTEPAD.exe " + Private Sub 统计_Click() CommonDialog1.FileName, vbNormalFocus) End Sub Dim max%, min%, ave!, m%, n% max = List1.List(0) Private Sub return_Click(Index As Integer) min = List1.List(0) Form6.Show ave = List1.List(0) Unload Form5 m = 0 End Sub n = 0 For i = 1 To List1.ListCount - 1 G(8 If max < List1.List(i) Then max = List1.List(i): m = i G(9 If min > List1.List(i) Then min = List1.List(i): n = i Private Sub 结束_Click() ave = ave + List1.List(i) Next i m = i Form2.Text1 = List1.List(n) If min > List1.List(i) Then min = List1.List(i): n Form2.Text2 = List1.List(m) = i Form2.Text3 = Format(ave / List1.ListCount, ave = ave + List1.List(i)"0.00") Next i Form2.Show stat2.Text1 = List1.List(n) stat2.Text2 = List1.List(m) End Sub stat2.Text3 = Format(ave / List1.ListCount, "0.00") stat2.Show G(10 End Sub Private Sub experimentG2_Click() Form2.Show Private Sub Text1_MouseDown(Button As Integer, End Sub Shift As Integer, X As Single, Y As Single) If Button = 2 Then PopupMenu caidan2, Private Sub experimentG3_Click() vbPopupMenuCenterAlign Form3.Show End Sub End Sub Private Sub xie_Click() Private Sub experimentG4_Click() Text1.Font.Italic = Not Text1.Font.Bold Form4.Show End Sub End Sub H(1 Private Sub experimentG5_Click() Private Sub Command1_Click() Form5.Show Open "c:\score" For Output As #1 End Sub Print #1, "051023", "王海涛", 66 Private Sub font_12_Click() Print #1, "052498", "周文英", 88 Text1.FontSize = 12 End Sub Print #1, "050992", "陈建东", 77 Private Sub font_16_Click() Open "c:\score1" For Output As #2 Text1.FontSize = 16 Write #2, "051023", "王海涛", 66 End Sub Write #2, "052498", "周文英", 88 Private Sub rnd10_Click() Randomize Write #2, "050992", "陈建东", 77 For i = 0 To 9 List1.List(i) = Int(Rnd * 30 + 70) Close Next i i1 = Shell("NOTEPAD.exe" + " c:\score", End Sub vbNormalNoFocus) i2 = Shell("NOTEPAD.exe" + " c:\score1", Private Sub stat_Click() vbNormalNoFocus) Dim max%, min%, ave!, m%, n% End Sub max = List1.List(0) min = List1.List(0) Private Sub Command2_Click() ave = List1.List(0) Dim no As String, name As String, s As Integer m = 0 Open "c:\score" For Input As #1 n = 0 Do While Not EOF(1) For i = 1 To List1.ListCount - 1 Line Input #1, linedata If max < List1.List(i) Then max = List1.List(i): List1.AddItem linedata Loop Dim student As studtype, stud(1 To 5) As studtype, Open "c:\score1" For Input As #2 t As studtype Do While Not EOF(2) Input #2, no, name, s Private Sub Command1_Click() List2.AddItem no & name & s Open "d:\score.dat" For Random As #1 Len = Loop Len(student) Close With studentEnd Sub .no = "0001" .name = "星期一" H(2 Private Sub Command1_Click() .mark = 66 Dim fib%(0 To 9), i% End With Open "c:\fb.dat" For Output As #1 Put #1, 1, student For i = 0 To 9 With student If i = 0 Or i = 1 Then .no = "0002" fib(i) = i .name = "星期二" Else fib(i) = fib(i - 1) + fib(i - 2) .mark = 99 End If End With Print #1, """Fib(" & i & ")""," & fib(i) Put #1, 2, student Next i With student Close #1 .no = "0003" i = Shell("NOTEPAD.exe" + " c:\fb.dat", .name = "星期三" vbNormalNoFocus) End Sub .mark = 88 End With Private Sub Command2_Click() Put #1, 3, student Dim st$, n%, sum% With student Open "c:\fb.dat" For Input As #1 .no = "0004" Do While Not EOF(1) .name = "星期四" Input #1, st, n sum = sum + n .mark = 55 List1.AddItem st & "=" & n End With Loop Put #1, 4, student Close #1 With student .no = "0005" List1.AddItem "合计:" & sum .name = "星期五" List1.AddItem "平均:" & sum / 10 .mark = 77 End Sub End With Put #1, 5, student H(3 Close #1 End Sub H(4 Private Type studtype Private Sub Command2_Click() no As String * 4 Open "d:\score.dat" For Random As #1 Len = name As String * 6 Len(student) mark As Single For i = 1 To 5 End Type Get #1, i, student Print student.no, student.name, student.mark Close #1stud(i) = student End Sub Next i Close #1 Private Sub Command2_Click() For i = 1 To 5 Open "c:\score" For Random As #1 Len = Len(std) For j = i + 1 To 5 record = Val(Text4.Text) If stud(i).mark > stud(j).mark Then t = stud(i): Get #1, record, std stud(i) = stud(j): stud(j) = t Text1.Text = std.no Next Text2.Text = std.name Next i If std.sex = "1" Then Open "d:\random1.dat" For Random As #2 Len = Option1.Value = True Len(student) Else For i = 1 To 5 Option2.Value = True Put #2, i, stud(i) End If Next i Text3.Text = std.mark Close #1 record = LOF(1) / Len(std) End Sub Close #1 End Sub Private Sub Command3_Click() Open "d:\random1.dat" For Random As #1 Len = Private Sub Command3_Click() Len(student) With std For i = 1 To 5 .no = Val(Text1.Text) Get #1, i, stud(i) .name = Text2.Text Print stud(i).no; stud(i).name; stud(i).mark .sex = IIf(Option1.Value, "1", "0") Next i .mark = Val(Text3.Text) Close #1 End With Open "c:\score" For Random As #1 Len = Len(std) End Sub record = Val(Text4.Text) Put #1, record, std H(5 Close #1 Private Type studtype End Sub no As Integer name As String * 20 Private Sub Command4_Click() sex As String * 1 Open "c:\score" For Random As #1 Len = Len(std) mark As Single record = 1 End Type Get #1, record, std Dim std As studtype Text1.Text = std.no Dim record As Integer Text2.Text = std.name If std.sex = "1" Then Private Sub Command1_Click() Option1.Value = True With std Else .no = Val(Text1.Text) Option2.Value = True .name = Text2.Text End If .sex = IIf(Option1.Value, "1", "0") Text3.Text = std.mark .mark = Val(Text3.Text) record = LOF(1) / Len(std) End With Close #1 Open "c:\score" For Random As #1 Len = Len(std) Text4.Text = 1 record = LOF(1) / Len(std) + 1 End Sub Label1.Caption = record Put #1, record, std Private Sub Command5_Click() Open "c:\score" For Random As #1 Len = Len(std) Get #1, record, stdrecord = Val(Text4.Text) - 1 Text1.Text = std.no If Val(Text4.Text) <= 1 Then Text2.Text = std.name If std.sex = "1" Then MsgBox "超出记录范围", 2 + vbExclamation, "警Option1.Value = True Else 告": Close #1 Option2.Value = True Else End If Get #1, record, std Text3.Text = std.mark Text1.Text = std.no record = LOF(1) / Len(std) Text2.Text = std.name Close #1 If std.sex = "1" Then Text4.Text = record Option1.Value = True End Sub Else Option2.Value = True Private Sub Form_Load() End If Open "c:\score" For Random As #1 Len = Len(std) Text3.Text = std.mark Label1.Caption = LOF(1) / Len(std) record = LOF(1) / Len(std) Close #1 Close #1 End Sub Text4.Text = Val(Text4.Text) - 1 H(6 End If End Sub Private Type studtype no As Integer Private Sub Command6_Click() name As String * 6 Open "c:\score" For Random As #1 Len = Len(std) mark As Integer record = Val(Text4.Text) + 1 End Type If record > Val(Label1.Caption) Then Dim std As studtype Dim record As Integer MsgBox "超出记录范围", 2 + vbExclamation, "警 Private Sub Command1_Click() 告": Close With std Else .no = Val(Text1.Text) Get #1, record, std .name = Text2.Text Text1.Text = std.no .mark = Val(Text3.Text) Text2.Text = std.name End With If std.sex = "1" Then Open "c:\score1" For Random As #1 Len = Option1.Value = True Len(std) Else record = LOF(1) / Len(std) + 1 Option2.Value = True Put #1, record, std End If Close #1 Text3.Text = std.mark Text1.Text = "" record = LOF(1) / Len(std) Text2.Text = "" Close #1 Text3.Text = "" Text4.Text = Val(Text4.Text) + 1 Text1.SetFocus End If End Sub End Sub Private Sub Command2_Click() Private Sub Command7_Click() Dim sum, count As Integer Open "c:\score" For Random As #1 Len = Len(std) Open "c:\score1" For Random As #1 Len = record = Val(Label1.Caption) Len(std) For i = 1 To record If Dir(fname1) <> "" Then Get #1, i, std fnum = FreeFile sum = sum + std.mark Open fname1 For Binary As #fnum count = count + 1 flen1 = LOF(fnum)List1.AddItem std.no & " " & std.name & ReDim byt1(flen1 - 1) std.mark Get #fnum, 1, byt1() Next i Close fnum End If List1.AddItem "总分" & sum If Dir(fname2) <> "" Then fnum = FreeFile List1.AddItem "平均成绩" & sum / count Open fname2 For Binary As #fnum Close #1 flen2 = LOF(fnum) End Sub ReDim byt2(flen2 - 1) Get #fnum, 1, byt2() H(7 Close fnum Private Sub Command1_Click() End If Dim inputdata1, inputdata2, inputdata3 As String * 1 Close Dim v, byt1() As Byte, byt2() As Byte, flen1 As End Sub Long, flen2 As Long, fnum, fnum3 As Integer J-4 Text1.Text = "": Text2.Text = "": Text3.Text = "" Private Sub Command1_Click() Dim strb() As Byte CommonDialog1.ShowOpen CommonDialog1.ShowOpen fname1 = CommonDialog1.FileName Open CommonDialog1.FileName For Binary As CommonDialog2.ShowOpen #1 fname2 = CommonDialog2.FileName f1 = LOF(1) Open fname1 For Binary As #1 ReDim strb(f1) Open fname2 For Binary As #2 Get #1, , strb Adodc1.Recordset.Fields("照片").AppendChunk Do While Not EOF(1) strb inputdata1 = Input(1, #1) Close #1 Text1.Text = Text1.Text + inputdata1 Image1.Picture = Loop LoadPicture(CommonDialog1.FileName) End Sub Do While Not EOF(2) inputdata2 = Input(1, #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 EOF(fnum3) inputdata3 = Input(1, #fnum3) Text3.Text = Text3.Text + inputdata3 Loop
本文档为【 VB程序设计教程&#40;第3版&#41;课后实验答案】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_591137
暂无简介~
格式:doc
大小:87KB
软件:Word
页数:0
分类:
上传时间:2017-10-17
浏览量:21