VB实验指导书答案
【参考文档】vb实验指导书答案-范文word版 (10页)
第6章 过程
一、单选题
二、填空题 2.5 5. 工具 7. &,Click 8. Enabled 9. 窗体
10. 模式,无模式
11. Action
12. CommonDialog1.FileName 13. cdlCCRGBInit 14. Unload,Show 15. 所在窗体的名称 16. 打开 17. Visible 18. 当前 19. 255 20. Show
(6)强制显式声明变量 (7)类 P35 第三章
1. CBAAABCDAD ABBBC ADDBD 2.(1)integer (2)???? (3)text (4)a=0 or b=0 (5)(x+y)*sin(30*3.14/180) (6)int(rnd*100+1)(7)# (8)0
1
C
(9)int(rnd*30+70)(10) CDEF P53 第四章
本文部分内容来自网络整理,本司不为其真实性负责,如有异议或侵权请及时联系,本司将立即删除!
== 本文为word格式,下载后可方便编辑和修改! ==
vb实验指导书答案
篇一:VB程序设计学习与实验指导书答案(包含实验答案)
VB学习与实验指导测试题
参考答案
第一章
第二章
第三章
第四章
第五章
第六章
第七章
第八章
篇二:VB实验指导书答案
VB实验指导书_理论综合练习题_答案(完结版).doc
第二部分综合练习理论练习一一单选1-5 CDCCB 640ABDCD 11-15 CCBBD 16-20 DBCBA二多选1 ABCE 2CE 3 BCE 4 ADE 5 ABCD6ABCDE 7ACD8ABCDE 9 ABC 10ABCDE三判断1-5 X V X V V6-10 V X V V V四填空1 x=int(Rnd*101)End If avg=s/82 i=l to 10Right(str(i),l)或Right(str(i mod 10))3 m*n/GCD(m,n)GCD(b, a mod b)4 Exit For i & “是素数”Next i五阅读程序1-4 DDCB六程序设计1Option Base 1Private Sub Form_click()Dim a( 10)Ciscreatedata a()sort a()Fori= ITo 10Print a(i);Next iEnd SubSub createdata(a())Fori = ITo 10a(i) = Int(Rnd * 101)Next iEnd SubSub sort(a())For i = 1 To 9Forj = 1 To 10-iIf a(j) > a(j + l)Thent = a(j): a(j) = a(j + 1): a(j + 1) = tEnd IfNext jNext iEnd Sub2Private Type ksno As String * 8Bscj As IntegerSjcj As IntegerEnd TypeDim student As ksPrivate Sub Form_Load()Open "c:\ksxx.dat" For Random As#l Len = Len(student)End SubPrivate Sub cmdadd_Click()student.no = Text 1.Textstudent.Bscj = Val(Text2.Text)student.Sjcj = Vai (Tex t3.Text)lastrecord = LOF( 1) / Len(student) + 1Put # 1, lastrecord, studentTextl.Text =Text2.Text = ””Text3.Text ="End SubPrivate Sub cmdquit_Click()Close #1EndEnd Sub1-5 CABCD理论练习二6-10 ABCCD 11-15 BBBAB1 CD2 AD3CE4BC6BCDE7CDE8ABCDE9 ABD三判断二多选1-5 X X X X V 6-10 V V V X X 16-20 DBAAC5 AD10ACDE1n-l 或者Sqr (n)02X y3 1 to 102*i-14Button=2start=True 五阅读程序1-5DBDAB六程序设计1Private Sub Form_click()四填空japan = 47528china = 22257n = 0 True — (x, y)Do While china <= japanchina = china * 1.098japan = japan * 1.028 n= n + 1LoopPrint n & ”年之后,中国GDP将超过日本”End Sub•VB6中的Split函数,其功能足将一字符巾用分界符分割为一字符串数组。
VB程序设计教程实验指导与习题解答上机答案
程序代码Private Sub Command1_Click()End SubPrivate Sub Command2_Click() = TrueEnd SubPrivate Sub Command3_Click() = TrueEnd SubPrivate Sub Command4_Click() = 10 = False = FalseEnd Sub初始窗口:单机放大之后窗口:单机下划线之后窗口:单击加粗之后窗口:自测2单击还原之后窗口:Private Sub Command1_Click()Label1 = "visual basic"Text1 = " 程序设计题"End SubPrivate Sub Command2_Click()Text1 = "visual basic"Label1 = " 程序设计题"End Sub初始窗口:单击显示之后窗口:单击交换之后的窗口:自测题3Private Sub Command1_Click()End SubPrivate Sub Command2_Click() = + 30End Sub= + 20= 1初始窗口:单击缩小两倍之后的窗口:单击向右下角移动之后的窗口:自测题4程序代码Private Sub Command1_Click() = "VB 学习"Print"简单的VB程序设计"End SubPrivate Sub Command2_Click()ClsEnd SubPrivate Sub Command3_Click()EndEnd SubPrivate Sub Command3_Click()EndEnd Sub初始化窗口:单击显示之后的窗口:单击清除之后的窗口:自测题5单击退出之后的窗口:Private Sub Comma nd1_Click()HHEnd SubPrivate Sub Comma nd2_Click() =Val + Val End SubPrivate Sub Comma nd3_Click() End End Sub初始化窗口: 单击运算之后窗口: 单击清除之后的窗口:也 I 绘I lirr-:輕 g砖屮 ZBPL H J ^E 霸赴 BAy 噹晔了 ZILT. 相0 ■tap乜=1 业 '-JS-J Q -•ST F■ I” _l ■■ B 事电r 兴/涉审叭暂背巧応科1I gMd I T B ' A bJ El -; F 」 )-1 a □瓷 a QB aitr 硕八— y -I Su日 r>M| PLi.l CnhwJ x> 蚀-7 -■nJ肝 k4・Jii.— Tr«:h^.L 33 -:呻p Ju IpL*口- i-JN h —vid.]F TM IHFLlMv ■ -UKncnm-'|LUIPI> r■41•成 &.■ B WOQULL,:■—PMd P GPrivate Sub Command1_Click()Dim a$= Left(a, 2)End SubPrivate Sub Command2_Click()= Right(a, 2)End SubPrivate Sub Command3_Click()End Sub初始窗口界面输入字符串截取前两个字符截取后两个字符字符串连接自测练习2 Private Sub Form_Click()Dim a%, b%, c%, d%, e%, f%, g%, h%, i%, j%, k%, l% a = 7349e = a Mod 10 ' 个位d = (a \ 10) Mod 10 ' 十位c = (a \ 100) Mod 10 ' 百位b = a \ 1000 ' 千位i = (e + 7) Mod 10 ' 个位h = (d + 7) Mod 10 ' 十位g = (c + 7) Mod 10 ' 百位f = (b + 7) Mod 10 ' 千位交换后的个位交换后的千位交换后的十位交换后的百位l = f * 1000 + g * 100 + h * 10 + i = FalsePrint " 加密前的4位整数是7439"; (Chr(10)); " 加密后的结果是"; l End Sub初始界面单击窗体运行后的界面自测练习1Private Sub Form_Click()Dim a%, b%, c%, d%, e%, f!a = Val(InputBox(" 输入第一个数", "b = Val(InputBox(" 输入第一个数", "f = Fix(f * 100 + / 100& "x/y=" & f, , " 输出的结果"End Sub自测练习2Private Sub Form_Click()Dim a%, b%, c%, d%, e%, f!Print " 和="; ePrint " 平均值="; f 输入一个数", 8)) 输入一个数", 7))MsgBox"x+y=" & c & Chr(10) & "x-y=" & d & Chr(10) & "x*y=" & e & Chr(10)a = Val(InputBox(" 输入第一个数的值"))b = Val(InputBox(" 输入第二个数的值"))c = Val(InputBox(" 输入第三个数的值"))d = Val(InputBox(" 输入第四个数的值"))End Sub自测练习3Private Sub Form_Click()Dim h%, f%, x%, y%h = Val(InputBox(" 输入总头数"))f = Val(InputBox(" 输入总脚数"))x = (4 * h - f) / 2y = (f - 2 * h) / 2Print " 笼中鸡的头数为"; x; 只"Print " 笼中兔的头数为"; y; 只"End Sub自测练习1:Private Sub Form_Click()Dim a%, b%, c%a = Val(InputBox(" 请输入第一条边", " 边长"))b = Val(InputBox(" 请输入第二条边", " 边长"))c = Val(InputBox(" 请输入第三条边", " 边长"))If a + b > c And a + c > b And b + c > a ThenIf a * a + b * b = c * c Or a * a + c * c = b * b Or b * b = c * c = a * a ThenPrint " 直角"ElseIf a = b And b = c ThenPrint " 等边三角形"ElseIf a = b Or a = c Or b = c ThenPrint " 等腰三角形"ElsePrint " 一般三角形"End IfElsePrint " 不是三角形"End IfEnd Sub不是三角形运行结果:初始窗口:输入三条边:运行结果:直角三角形运行结果:等边三角形运行结果如下:等腰三角形:般三角形自测练习2:Private Sub Form_Click()Dim a%, b!a = Val(InputBox(" 请输入"))If a Mod 2 = 0 And a Mod 3 = 0 And a Mod 5 = 0 Then b = Sqr(a)Print a, bElseEndEnd IfEnd Sub初始化窗口: 输入一个数: 运行结果: 自测练习3Private Sub Comma nd1_Click()Dim a%, b% a = ValSelect Case a > 0Case a < 20MsgBox "行李费为元/kg",," 行李费Case a >= 20 And a < 50MsgBox "行李费为元/kg",," 行李费Case a >= 50 And a < 100MsgBox "行李费为元/kg",," 行李费Case Elseb = * 100 + (a - 100) * : MsgBox " 行李费为"& b & "元",,"行李费End SelectEnd Sub初始窗口: 输入10: 输入25: 输入55: 输入120: 自测练习1Op tio n Base 1Private Sub Form_Click()Dim i%, a(1 To 20) As In teger a(1) = 1: a(2) = 1Print a(1);Print a(2);For i = 3 To 10 a(i) = a(i - 1) + a(i - 2)Print a(i);Next iPrintFori = 11 To 16a(i) = a(i - 1) + a(i - 2)Print a(i);Next iPrintFor i = 17 To 20 a(i) = a(i - 1) + a(i - 2) Print a(i);Next i初始界面:运行结果界面:自测练习2Option Base 1Private Sub Form_Load()= 10000= 5000End SubPrivate Sub Command1_Click()Dim i%, j%, t%, a(1 To 4, 1 To 4) As Integer For i = 1 To 4For j = 1 To 4 a(i, j) = Int(Rnd * 10) + 1a(i, j);Next jNext i " 对角线的元素如下"For i = 1 To 4 a(i, i);Next iFor i = 1 To 4 a(i, 5 - i);Next iFor i = 1 To 4 t = a(1, i) a(1, i) = a(4, i) a(4, i) = t Next iFor i = 1 To 4 t = a(i, 2) a(i, 2) = a(i, 3) a(i, 3) = t Next iFor i = 1 To 4Forj = 1 To 4 a(i, j);Next jNext iEnd Sub运行初始界面:运行结果界面: 自测练习1Sub itostr(a As In teger)Dim b%, c$ a = VaiWhile a >= 1 c = Chr(a Mod 10+ 48) & c0 Fornnl施机;^生的拒畔相应处運输入矩阵茹处理般曲越$a = a \ 10WendEnd SubPrivate Sub Command1_Click()Dim a As Integer a = ValCall itostr(a)End Sub运行初始界面:运行结果界面:验证其他数字:自测练习2:Public Function area(n) As DoubleDim c#, d#, e#, s# n = Val c = (1 - 0) / nWhile e <= 1 d = I * c: e = (I + 1) * c s = s + (Sin(d) + Sin(e)) * c / 2 area = s WendEnd FunctionPrivate Sub Command1_Click()Dim s As DoubleCall area(n) = area(n)End Sub运行初始界面:运行结果:自测练习3Private Sub Form_click() n =Val(InputBox(" 请输入n 的值")) x = Val(InputBox(" 请输入x 的值"))Print "e 的值="; es(n, x)End SubPrivate Function es(n, x)Dim a As Double, b As Double, c As Double, i As Integer a = 1: b = 1: c = 1For i = 1 To n a = x * a: b = b * i: c = c + a / bNext i es = cEnd Function运行初始界面:输入数据:运行结果:自测练习4:For i = 1 To 4For j = i + 1 To 5If a(i) > a(j) Thent = a(i): a(i) = a(j): a(j) = tEnd IfNext jNext iFor i = 1 To 5Print a(i); " ";Next iFor i = 1 To 5If Y < a(i) Thent = a(i): a(i) = Y: Y = tEnd IfNext iFor i = 1 To 6a(6) = tNext iEnd FunctionPrivate Sub Command1_Click()Dim i#, a%(1 To 6), Y%Y = Val(InputBox(" 输入y 的值", " 输入数据"))Insertfun a%(), YPrintFor i = 1 To 6Print a(i); " ";Next iEnd Sub运行初始界面:插入数据:运行结果:自测练习1:Private Sub Command1_Click()If = 1 Then = " 报名参加羽毛球比赛" End IfIf = 1 Then = " 报名参加乒乓球比赛"If = 1 And = 1 ThenEnd If= " 报名参加羽毛球,乒乓球比赛"End IfEnd Sub运行初始界面:运行结果:自测练习4:Private Sub Form_Load()= 24 = " 黑体" = &HFF&End SubPrivate Sub Option1_Click() = " 我是学生"End SubPrivate Sub Option2_Click() = " 我是教师"End SubPrivate Sub Option3_Click() = " 我是工人"Private Sub Option4_Click()End Sub= " 我是农民"End Sub运行初始界面:运行结果:自测练习6:Private Sub Command1_Click()For i = 0 To - 1If (i) = ThenExit ForEnd IfNext iIf i > - 1 ThenEnd IfEnd SubPrivate Sub Command2_Click()If <> -1 ThenFor i = 0 To - 1If (i) = ThenEnd IfExit ForNext iEnd IfEnd SubPrivate Sub Command3_Click()End Sub运行初始界面:自测练习7:Private Sub Command1_Click()= TrueEnd SubPrivate Sub Form_Load()= 20= 20= 20= 20End SubPrivate Sub Timer1_Timer() lbltem = = + 10If VSbwd >= 100 Then lbltishi = " 水开了" = FalseEnd IfEnd Sub运行初始界面:运行结果:自测练习1:Private Sub myhelp_Click()End SubPrivate Sub mymenu1_Click() = " 百货大楼"End SubPrivate Sub mymenu2_Click() = " 利客隆"End SubPrivate Sub mymenu3_Click() = " 稻香村"End Sub运行初始界面:运行结果界面:自测练习2:Private Sub Dis_Click() = " 菜单程序设计" = 20 = " 黑体"End SubPrivate Sub Hid_Click() = FalseEnd Sub运行初始界面:运行结果界面:自测练习3:Private Sub vbhelp_Click() r = MsgBox(" 帮助", , " 程序设计题")End SubPrivate Sub Vbnew_Click() r = MsgBox(" 新建", , " 程序设计题")End SubPrivate Sub vbopen_Click() r = MsgBox(" 打开", , " 程序设计题")End SubPrivate Sub vbsave_Click()自测练习1: r = MsgBox ("存盘”,," 程序设计题")End Sub运行初始界面: 运行结果: 自测练习4:Private Sub Comma nd1_Click()End Sub运行初始界面:打开萱我菊園(1):文件名oa ) ; I立件类型电》:Ir 以只读方式打开區IPrivate Sub Command1_Click()Dim a As String, n%, i%, j%我最近皈由 O ■ \ 27 我的文趋 岡上嘟居^41121(1£S □141130110041145029 口 411旳[)13_辛诒_经济L1D1 亡J jag 己1« iT^ Temp 匚PySoEt 巴第五次实脸要貳文楼 □新建文件夹g2O074£3LS294SS£4 总听ni咫S ! O S6u_p L nyi n J& 1tfySystem已義单SCX倉第五欢实脸要求丈档四寫件基^操作测试內容回数据1国數据1®数据l.dbc0掏门鄱爰甘濒SllfU 实甜直评d Hl 取消Open "E:\" For Input As #1Input #1, a n = Len(a)For i = 1 To nIf Mid(a, i, 1) = "%" Then j = j + 1 Next iClose #1Open "E:\" For Output As #1Print #1, jClose #1End Sub运行初始界面:运行结果:自测练习3:Private Sub Form_Click()Dim x$Open "e:\" For Input As #1Do While Not EOF(1)LoopClose #1Open "e:\" For Append As #1Print #1, x$Close #1Line Input #1, x$运行初始界面:自测练习4Private Sub Form_load()Print " 26 个英文字母"PrintPrint " a b c d e f g h i j k l m n o p q r s t u v w x y z" Print " 字母个数分别为"End SubPrivate Sub Form_Click()Open "E:\" For Output As #1文本$ = InputBox(" 请输入文本") n = UCase( 文本$)Print #1, nOpen "E:\" For Output As #1For i = 1 To Len(n)ReDim Preserve a(1 To 26) j = Asc(Mid(n, i, 1)) - 64 a(j) = a(j) + 1Next iClose #1For j = LBound(a) To UBound(a)Print a(j);Next jClose #1Dim a%()。
大学计算机VB实验答案
计算机VB实验内容实验二1. 《实践指导》P10,实验1,设计一个加法器程序(请参考本次实验中实例2)。
(程序实际运行效果可参考程序“Prg3.exe” )保存要求:(1)在lab02文件夹中新建子文件夹“prg3”,用于保存本题的程序;(2)将本题的工程文件命名为“project3.vbp”,窗体文件命名为“form3.frm”。
注:该题的第5项要求中关于“同时第一个文本框获得焦点”部分不要求实现过程Private Sub Command1_Click()Dim a As Single, b As Single, c As Singlea = Val(Text1.Text)b = Val(Text2.Text)c = a + bLabel2 = cEnd SubPrivate Sub Command2_Click()Text1.Text = ""Text2.Text = ""Label2 = ""End Sub2. 编写一个标签变化程序(请参考本次实验中实例题1来完成,如下图1所示)(程序实际运行效果可参考程序“Prg4.exe” )保存要求:(1)在lab02文件夹中新建子文件夹“prg4”,用于保存本题的程序;(2)将本题的工程文件命名为“project4.vbp”,窗体文件命名为“form4.frm”。
设计要求:(1)单击窗体(Form1),则窗体打印输出文字“你点击了窗体”(如下图2所示)(2)单击按钮Command1,则在Label1中显示“你点击了按钮Command1,请进入”,字体大小15磅,字体为宋体(如下图3所示)(3)单击按钮Command2,Label1显示“你点击了按钮Command2,请离开”,字体大小25磅,字体为黑体(如下图4所示)(图1)(图2)(图3)(图4)过程Private Sub Command1_Click()Label1.FontSize = 15Label1.FontName = "宋体"Label1 = "你点击了按钮Command1,请进入"End SubPrivate Sub Command2_Click()Label1.FontSize = 25Label1.FontName = "黑体"Label1 = "你点击了按钮Command2,请离开"End SubPrivate Sub Form_Click()Form1.Print "你点击了窗体"End Sub实验三二、设计题1.《实践指导》P20,实验3。
VB实验报告(含答案)
If Check1.Value = 1 Then
Label1.FontBold = True
Else
Label1.FontBold = False
End If
If Check2.Value = 1 Then
Label1.FontItalic = True
Else
Label1.FontItalic = False
图1.1实验1-1运行界面
三.实验结果:对象属性设置
对象
属性
属性值
说明
Form1
caption
我的第一个vb程序
窗体
Label1
caption
请输入姓名
标签
Text1
text
““
文本框
Command1
caption
显示
命令按钮
Command2
caption
清除
命令按钮
四.实验思考:
1.标签label控件设置的属性代码有哪些?
加粗
复选框
Check2
Caption
倾斜
复选框
Check3
Caption
下划线
复选框
Check4
Caption
删除线
复选框
四.实验思考:
1.模拟简易计算器Command1命令的单击事件的程序代码是什么?
Private Sub Command1_Click()
Dim a!, b!
Dim c As String
If Option1.Value = True Then
Label1.FontName = “宋体”
ElseIf Option2.Value = True Then
VB实验指导书_理论综合练习题_答案(完结版)
第二部分综合练习理论练习一一单选1-5 CDCCB 6-10 ABDCD 11-15 CCBBD 16-20 DBCBA 二多选1 ABCE2 CE3 BCE4 ADE5 ABCD6 ABCDE7 ACD8 ABCDE9 ABC 10 ABCDE三判断1-5×√×√√6-10 √×√√√四填空、1 x=int(Rnd*101) End If avg=s/82 i=1 to 10 Right(str(i),1) 或Right(str(i mod 10))3 m*n/GCD(m,n) GCD(b, a mod b)4 Exit For i & “是素数”Next i五阅读程序1-4 DDCB六程序设计1Option Base 1Private Sub Form_click()Dim a(10)Clscreatedata a()sort a()For i = 1 To 10Print a(i);Next iEnd SubSub createdata(a())For i = 1 To 10a(i) = Int(Rnd * 101)Next iEnd SubSub sort(a())For i = 1 To 9For j = 1 To 10 - iIf a(j) > a(j + 1) Thent = a(j): a(j) = a(j + 1): a(j + 1) = tEnd IfNext jNext iEnd Sub2Private Type ksno As String * 8Bscj As IntegerSjcj As IntegerEnd TypeDim student As ksPrivate Sub Form_Load()Open "c:\ksxx.dat" For Random As #1 Len = Len(student) End SubPrivate Sub cmdadd_Click()student.no = Text1.Textstudent.Bscj = V al(Text2.Text)student.Sjcj = V al(Text3.Text)lastrecord = LOF(1) / Len(student) + 1Put #1, lastrecord, studentText1.Text = ""Text2.Text = ""Text3.Text = ""End SubPrivate Sub cmdquit_Click()Close #1EndEnd Sub理论练习二一单选1-5 CABCD 6-10 ABCCD 11-15 BBBAB 16-20 DBAAC 二多选1 CD2 AD3 CE4 BC5 AD6 BCDE7 CDE8 ABCDE9 ABD 10 ACDE三判断1-5××××√6-10 √√√××四填空1 n-1 或者Sqr(n) 0 True2 x y3 1 to 10 2*i-14 Button=2 start=True -(x,y)五阅读程序1-5 DBDAB六程序设计1Private Sub Form_click()japan = 47528china = 22257n = 0Do While china <= japanchina = china * 1.098japan = japan * 1.028n = n + 1LoopPrint n & "年之后,中国GDP将超过日本"End Sub2' VB6中的Split函数,其功能是将一字符串用分界符分割为一字符串数组。
VB实验报告答案 txt
End Sub
方法二
Private Sub Command1_Click()
x = InputBox("请输入弧度数值", "弧度转换", 0)
xx = Val(x)
Dim x!, a!, aa%, b!, bb%, c!, cc$
x = Val(Text1)
a = x * 180 / 3.14
aa = Int(a)
b = (a - aa) * 60
bb = Int(b)
c = (b - bb) * 60
cc = Format(c, "#.000")
If x > y Then
t = x: x = y: y = t
End If
End If
Label1 = x & Space(5) & y & Space(5) & z
End Sub
2-4
方法一
Private Sub Command1_Click()
x = Val(InputBox("请输入上网时间:"))
End Sub
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
VB实验指导书课后习题答案2016版
VB实验指导书课后习题答案2016版VB作业参考答案(xx年3月)第1次习题 VB程序设计概述一、选择题 1 A 2 A 3 D4 C5 A6 C7 C8 B9 B 二、1、在设计阶段利用属性窗口直接设置对象的属性值,程序运行时不能改变;2、在程序运行阶段通过赋值语句实现,即通过事件触发修改属性。
对象名.属性名=属性值第2次习题 VB可视化编程基础一、选择题 1 A 2 D 3B 4C 5 A 6 B 7 C 8 B 9 A 10 C 二、填空1 2 3第3次习题 VB语言基础一、选择题 1 BH 二、 1 231AutoSize MultiLine PasswordChar 2 B 3 C 4 B 5 A 6B 7 B 8C 9 B 10 C 11 C Abs(x+y)+Z^5 /(x*y) /(2*+EXP(X+Y))三、1 2 3 4 四、1 2 3 4 5 6第4次习题 VB控制结构一、选择chr(int(rnd*4)+65) int(rnd*90)+10 x mod 5=0 or x mod 7=0 10*(x mod 10)+x\\10 或 StrReverse(x) 188 30306 876554 ;8819 VISUAL C++ Programming 1 B 11 D 21 A2 D 12 A 22 C3 A 13 A 23 C4 B 14 B5 D 15 A6 B16 D 7 B 17 B 8 C 18 D 9 A 19 B 10 B 20 A 二、填空1 2 3270 Result * x m ; t ; m 三、程序设计题1. 求函数的值。
Dim y As Long, x As Integer, i%x = InputBox(\输入X的值:\ 或者 x=val() If x ElseIf x ElseIf x y = x * x 'or y=x^2 Elsey = 25 - x End IfPrint \2. 计算机:1+3+5+……+99的值。
VB程序设计学习与实验指导答案-推荐下载
对全部高中资料试卷电气设备,在安装过程中以及安装结束后进行高中资料试卷调整试验;通电检查所有设备高中资料电试力卷保相护互装作置用调与试相技互术关,系电通,力1根保过据护管生高线产中0不工资仅艺料可高试以中卷解资配决料置吊试技顶卷术层要是配求指置,机不对组规电在范气进高设行中备继资进电料行保试空护卷载高问与中题带资2负料2,荷试而下卷且高总可中体保资配障料置2试时32卷,3各调需类控要管试在路验最习;大题对限到设度位备内。进来在行确管调保路整机敷使组设其高过在中程正资1常料中工试,况卷要下安加与全强过,看度并25工且52作尽22下可护都能1关可地于以缩管正小路常故高工障中作高资;中料对资试于料卷继试连电卷接保破管护坏口进范处行围理整,高核或中对者资定对料值某试,些卷审异弯核常扁与高度校中固对资定图料盒纸试位,卷置编工.写况保复进护杂行层设自防备动腐与处跨装理接置,地高尤线中其弯资要曲料避半试免径卷错标调误高试高等方中,案资要,料求编试技5写、卷术重电保交要气护底设设装。备备置管4高调、动线中试电作敷资高气,设料中课并技3试资件且、术卷料中拒管试试调绝路包验卷试动敷含方技作设线案术,技槽以来术、及避管系免架统不等启必多动要项方高方案中式;资,对料为整试解套卷决启突高动然中过停语程机文中。电高因气中此课资,件料电中试力管卷高壁电中薄气资、设料接备试口进卷不行保严调护等试装问工置题作调,并试合且技理进术利行,用过要管关求线运电敷行力设高保技中护术资装。料置线试做缆卷到敷技准设术确原指灵则导活:。。在对对分于于线调差盒试动处过保,程护当中装不高置同中高电资中压料资回试料路卷试交技卷叉术调时问试,题技应,术采作是用为指金调发属试电隔人机板员一进,变行需压隔要器开在组处事在理前发;掌生同握内一图部线纸故槽资障内料时,、,强设需电备要回制进路造行须厂外同家部时出电切具源断高高习中中题资资电料料源试试,卷卷线试切缆验除敷报从设告而完与采毕相用,关高要技中进术资行资料检料试查,卷和并主检且要测了保处解护理现装。场置设。备高中资料试卷布置情况与有关高中资料试卷电气系统接线等情况,然后根据规范与规程规定,制定设备调试高中资料试卷方案。
VB程序设计指导实验指导与习题解答上机答案
自测1程序代码Private Sub Command1_Click() Label1.FontSize = Label1.FontSize + 3End SubPrivate Sub Command2_Click() Label1.FontBold = TrueEnd SubPrivate Sub Command3_Click() Label1.FontUnderline = TrueEnd SubPrivate Sub Command4_Click() Label1.FontSize = 10Label1.FontBold = FalseLabel1.FontUnderline = FalseEnd Sub初始窗口:单机放大之后窗口:单机下划线之后窗口:单击加粗之后窗口:单击还原之后窗口:自测2程序代码Private Sub Command1_Click() Label1 = "visual basic"Text1 = "程序设计题"End SubPrivate Sub Command2_Click() Text1 = "visual basic"Label1 = "程序设计题"End Sub初始窗口:单击显示之后窗口:单击交换之后的窗口:自测题3Private Sub Command1_Click()Label1.FontSize = Label1.FontSize * (0.5) End SubPrivate Sub Command2_Click()Label1.Top = Label1.Top + 30Label1.Width = Label1.Width + 20Label1.Alignment = 1End Sub初始窗口:单击缩小两倍之后的窗口:单击向右下角移动之后的窗口:自测题4程序代码Private Sub Command1_Click() Form1.Caption = "VB学习" Print "简单的VB程序设计"End SubPrivate Sub Command2_Click() ClsEnd SubPrivate Sub Command3_Click() EndEnd SubPrivate Sub Command3_Click() EndEnd Sub初始化窗口:单击显示之后的窗口:单击清除之后的窗口:单击退出之后的窗口:自测题5程序代码Private Sub Command1_Click()Text1.Text = ""Text2.Text = ""End SubPrivate Sub Command2_Click()Text3.Text = Val(Text1.Text) + Val(Text2.Text) End SubPrivate Sub Command3_Click()EndEnd Sub初始化窗口:单击运算之后窗口:单击清除之后的窗口:单击退出之后的窗口:自测练习1Private Sub Command1_Click() Dim a$a = Text1.TextLabel1.Caption = Left(a, 2) End SubPrivate Sub Command2_Click() a = Text1.TextLabel2.Caption = Right(a, 2) End SubPrivate Sub Command3_Click()Text1.Text = Label1.Caption & Label2.Caption End Sub初始窗口界面输入字符串截取前两个字符截取后两个字符字符串连接自测练习2Private Sub Form_Click()Dim a%, b%, c%, d%, e%, f%, g%, h%, i%, j%, k%, l% a = 7349e = a Mod 10 '个位d = (a \ 10) Mod 10 '十位c = (a \ 100) Mod 10 '百位b = a \ 1000 '千位i = (e + 7) Mod 10 '个位h = (d + 7) Mod 10 '十位g = (c + 7) Mod 10 '百位f = (b + 7) Mod 10 '千位j = ii = f '交换后的个位f = j '交换后的千位k = hh = g '交换后的十位g = k '交换后的百位l = f * 1000 + g * 100 + h * 10 + iText1.Visible = FalsePrint "加密前的4位整数是7439"; (Chr(10)); "加密后的结果是"; lEnd Sub初始界面单击窗体运行后的界面自测练习1Private Sub Form_Click()Dim a%, b%, c%, d%, e%, f!a = Val(InputBox("输入第一个数", "输入一个数", 8))b = Val(InputBox("输入第一个数", "输入一个数", 7))c = a + bd = a - be = a * bf = a / bf = Fix(f * 100 + 0.5) / 100MsgBox "x+y=" & c & Chr(10) & "x-y=" & d & Chr(10) & "x*y=" & e & Chr(10) & "x/y=" & f, , "输出的结果"End Sub自测练习2Private Sub Form_Click()Dim a%, b%, c%, d%, e%, f!a = Val(InputBox("输入第一个数的值"))b = Val(InputBox("输入第二个数的值"))c = Val(InputBox("输入第三个数的值"))d = Val(InputBox("输入第四个数的值"))e = a + b + c + df = e / 4Print "和="; e Print "平均值="; f End Sub自测练习3Private Sub Form_Click()Dim h%, f%, x%, y%h = Val(InputBox("输入总头数")) f = Val(InputBox("输入总脚数")) x = (4 * h - f) / 2y = (f - 2 * h) / 2Print "笼中鸡的头数为"; x; "只" Print "笼中兔的头数为"; y; "只"End Sub自测练习1:Private Sub Form_Click() Dim a%, b%, c%a = Val(InputBox("请输入第一条边", "边长"))b = Val(InputBox("请输入第二条边", "边长"))c = Val(InputBox("请输入第三条边", "边长"))If a + b > c And a + c > b And b + c > a ThenIf a * a + b * b = c * c Or a * a + c * c = b * b Or b * b = c * c = a * a ThenPrint "直角"ElseIf a = b And b = c ThenPrint "等边三角形"ElseIf a = b Or a = c Or b = c ThenPrint "等腰三角形"ElsePrint "一般三角形"End IfElsePrint "不是三角形"End IfEnd Sub不是三角形运行结果:初始窗口:输入三条边:运行结果:直角三角形运行结果:等边三角形运行结果如下:等腰三角形:一般三角形自测练习2:Private Sub Form_Click()Dim a%, b!a = Val(InputBox("请输入"))If a Mod 2 = 0 And a Mod 3 = 0 And a Mod 5 = 0 Then b = Sqr(a)Print a, bElseEndEnd IfEnd Sub初始化窗口:输入一个数:运行结果:自测练习3Private Sub Command1_Click()Dim a%, b%a = Val(Text1.Text)Select Case a > 0Case a < 20MsgBox "行李费为0.2元/kg", , "行李费"Case a >= 20 And a < 50MsgBox "行李费为0.3元/kg", , "行李费"Case a >= 50 And a < 100MsgBox "行李费为0.4元/kg", , "行李费"Case Elseb = 0.2 * 100 + (a - 100) * 0.5: MsgBox "行李费为" & b & "元", , "行李费"End SelectEnd Sub初始窗口:输入10:输入25:输入55:输入120:自测练习1Option Base 1Private Sub Form_Click()Dim i%, a(1 To 20) As Integera(1) = 1: a(2) = 1Print a(1);Print a(2);For i = 3 To 10a(i) = a(i - 1) + a(i - 2) Print a(i);Next iPrintFor i = 11 To 16a(i) = a(i - 1) + a(i - 2) Print a(i);Next iPrintFor i = 17 To 20a(i) = a(i - 1) + a(i - 2) Print a(i);Next i初始界面:运行结果界面:自测练习2Option Base 1Private Sub Form_Load() Form1.Width = 10000 Form1.Height = 5000 End SubPrivate Sub Command1_Click()Dim i%, j%, t%, a(1 To 4, 1 To 4) As Integer For i = 1 To 4For j = 1 To 4a(i, j) = Int(Rnd * 10) + 1Picture1.Print a(i, j);Next jPicture1.PrintNext iPicture3.Print "对角线的元素如下"For i = 1 To 4Picture3.Print a(i, i);Next iPicture3.PrintFor i = 1 To 4Picture3.Print a(i, 5 - i);Next iFor i = 1 To 4t = a(1, i)a(1, i) = a(4, i)a(4, i) = tNext iFor i = 1 To 4t = a(i, 2)a(i, 2) = a(i, 3)a(i, 3) = tNext iFor i = 1 To 4For j = 1 To 4Picture2.Print a(i, j); Next jPicture2.PrintNext iEnd Sub运行初始界面:运运行结果界面:自测练习1Sub itostr(a As Integer) Dim b%, c$a = Val(Text1.Text)While a >= 1c = Chr(a Mod 10 + 48) & ca = a \ 10WendText2.Text = c End SubPrivate Sub Command1_Click()Dim a As Integera = Val(Text1.Text)Call itostr(a)End Sub运行初始界面:运行结果界面:验证其他数字:自测练习2:Public Function area(n) As Double Dim c#, d#, e#, s#n = Val(Text2.Text)c = (1 - 0) / nWhile e <= 1d = I * c:e = (I + 1) * cs = s + (Sin(d) + Sin(e)) * c / 2 I = I + 1Wendarea = sEnd FunctionPrivate Sub Command1_Click() Dim s As DoubleCall area(n)Text1.Text = area(n)End Sub运行初始界面:运行结果:自测练习3Private Sub Form_click()n = Val(InputBox("请输入n的值"))x = Val(InputBox("请输入x的值"))Print "e的值="; es(n, x)End SubPrivate Function es(n, x)Dim a As Double, b As Double, c As Double, i As Integer a = 1: b = 1: c = 1For i = 1 To na = x * a:b = b * i:c = c + a / bNext ies = cEnd Function运行初始界面:输入数据:运行结果:自测练习4:For i = 1 To 4For j = i + 1 To 5If a(i) > a(j) Thent = a(i): a(i) = a(j): a(j) = tEnd IfNext jNext iFor i = 1 To 5Print a(i); " ";Next iFor i = 1 To 5If Y < a(i) Thent = a(i): a(i) = Y: Y = tEnd IfNext iFor i = 1 To 6a(6) = tNext iEnd FunctionPrivate Sub Command1_Click()Dim i#, a%(1 To 6), Y%Y = Val(InputBox("输入y的值", "输入数据")) Insertfun a%(), YPrintFor i = 1 To 6Print a(i); " "; Next iEnd Sub运行初始界面:插入数据:运行结果:41011060蓝志鹏资源1102 实验8自测练习1:Private Sub Command1_Click()If Ch1.Value = 1 ThenText1.Text = "报名参加羽毛球比赛"End IfIf Ch2.Value = 1 ThenText1.Text = "报名参加乒乓球比赛"End IfIf Ch1.Value = 1 And Ch2.Value = 1 Then Text1.Text = "报名参加羽毛球,乒乓球比赛" End IfEnd Sub运行初始界面:运行结果:自测练习4:Private Sub Form_Load() Label1.Alignment = 2 Label1.FontSize = 24 Label1.FontName = "黑体" Label1.ForeColor = &HFF&End SubPrivate Sub Option1_Click() Label1.Caption = "我是学生" End SubPrivate Sub Option2_Click() Label1.Caption = "我是教师" End SubPrivate Sub Option3_Click() Label1.Caption = "我是工人" End SubPrivate Sub Option4_Click() Label1.Caption = "我是农民" End Sub运行初始界面:运行结果:。
vb程序设计教程实验指导与习题解答上机答案()
自测1程序代码Private Sub Command1_Click()Label1.FontSize = Label1.FontSize + 3 End SubPrivate Sub Command2_Click()Label1.FontBold = TrueEnd SubPrivate Sub Command3_Click()Label1.FontUnderline = TrueEnd SubPrivate Sub Command4_Click()Label1.FontSize = 10Label1.FontBold = FalseLabel1.FontUnderline = FalseEnd Sub初始窗口:单机放大之后窗口:单机下划线之后窗口:单击加粗之后窗口:单击还原之后窗口:自测2程序代码Private Sub Command1_Click()Label1 = "visual basic"Text1 = "程序设计题"End SubPrivate Sub Command2_Click()Text1 = "visual basic"Label1 = "程序设计题"End Sub初始窗口:单击显示之后窗口:单击交换之后的窗口:自测题3Private Sub Command1_Click()Label1.FontSize = Label1.FontSize * (0.5) End SubPrivate Sub Command2_Click()Label1.Top = Label1.Top + 30Label1.Width = Label1.Width + 20Label1.Alignment = 1End Sub初始窗口:单击缩小两倍之后的窗口:单击向右下角移动之后的窗口:自测题4程序代码Private Sub Command1_Click() Form1.Caption = "VB学习" Print "简单的VB程序设计" End SubPrivate Sub Command2_Click() ClsEnd SubPrivate Sub Command3_Click() EndEnd SubPrivate Sub Command3_Click() EndEnd Sub初始化窗口:单击显示之后的窗口:单击清除之后的窗口:单击退出之后的窗口:自测题5程序代码Private Sub Command1_Click()Text1.Text = ""Text2.Text = ""End SubPrivate Sub Command2_Click()Text3.Text = Val(Text1.Text) + Val(Text2.Text)End SubPrivate Sub Command3_Click()EndEnd Sub初始化窗口:单击运算之后窗口:单击清除之后的窗口:单击退出之后的窗口:自测练习1Private Sub Command1_Click()Dim a$a = Text1.TextLabel1.Caption = Left(a, 2)End SubPrivate Sub Command2_Click()a = Text1.TextLabel2.Caption = Right(a, 2)End SubPrivate Sub Command3_Click()Text1.Text = Label1.Caption & Label2.CaptionEnd Sub初始窗口界面输入字符串截取前两个字符截取后两个字符字符串连接自测练习2Private Sub Form_Click()Dim a%, b%, c%, d%, e%, f%, g%, h%, i%, j%, k%, l% a = 7349e = a Mod 10 '个位d = (a \ 10) Mod 10 '十位c = (a \ 100) Mod 10 '百位b = a \ 1000 '千位i = (e + 7) Mod 10 '个位h = (d + 7) Mod 10 '十位g = (c + 7) Mod 10 '百位f = (b + 7) Mod 10 '千位j = ii = f '交换后的个位f = j '交换后的千位k = hh = g '交换后的十位g = k '交换后的百位l = f * 1000 + g * 100 + h * 10 + iText1.Visible = FalsePrint "加密前的4位整数是7439"; (Chr(10)); "加密后的结果是"; l End Sub初始界面单击窗体运行后的界面自测练习1Private Sub Form_Click()Dim a%, b%, c%, d%, e%, f!a = Val(InputBox("输入第一个数", "输入一个数", 8))b = Val(InputBox("输入第一个数", "输入一个数", 7))c = a + bd = a - be = a * bf = a / bf = Fix(f * 100 + 0.5) / 100MsgBox "x+y=" & c & Chr(10) & "x-y=" & d & Chr(10) & "x*y=" & e & Chr(10) & "x/y=" & f, , "输出的结果"End Sub自测练习2Private Sub Form_Click()Dim a%, b%, c%, d%, e%, f!a = Val(InputBox("输入第一个数的值"))b = Val(InputBox("输入第二个数的值"))c = Val(InputBox("输入第三个数的值"))d = Val(InputBox("输入第四个数的值"))e = a + b + c + df = e / 4Print "和="; ePrint "平均值="; fEnd Sub自测练习3Private Sub Form_Click()Dim h%, f%, x%, y%h = Val(InputBox("输入总头数"))f = Val(InputBox("输入总脚数"))x = (4 * h - f) / 2y = (f - 2 * h) / 2Print "笼中鸡的头数为"; x; "只"Print "笼中兔的头数为"; y; "只"End Sub自测练习1:Private Sub Form_Click()Dim a%, b%, c%a = Val(InputBox("请输入第一条边", "边长"))b = Val(InputBox("请输入第二条边", "边长"))c = Val(InputBox("请输入第三条边", "边长"))If a + b > c And a + c > b And b + c > a ThenIf a * a + b * b = c * c Or a * a + c * c = b * b Or b * b = c * c = a * a ThenPrint "直角"ElseIf a = b And b = c ThenPrint "等边三角形"ElseIf a = b Or a = c Or b = c Then Print "等腰三角形"ElsePrint "一般三角形"End IfElsePrint "不是三角形"End IfEnd Sub不是三角形运行结果:初始窗口:输入三条边:运行结果:直角三角形运行结果:等边三角形运行结果如下:等腰三角形:一般三角形自测练习2:Private Sub Form_Click()Dim a%, b!a = Val(InputBox("请输入"))If a Mod 2 = 0 And a Mod 3 = 0 And a Mod 5 = 0 Then b = Sqr(a)Print a, bElseEndEnd IfEnd Sub初始化窗口:输入一个数:运行结果:自测练习3Private Sub Command1_Click()Dim a%, b%a = Val(Text1.Text)Select Case a > 0Case a < 20MsgBox "行李费为0.2元/kg", , "行李费"Case a >= 20 And a < 50MsgBox "行李费为0.3元/kg", , "行李费"Case a >= 50 And a < 100MsgBox "行李费为0.4元/kg", , "行李费"Case Elseb = 0.2 * 100 + (a - 100) * 0.5: MsgBox "行李费为" & b & "元", , "行李费"End SelectEnd Sub初始窗口:输入10:输入25:输入55:输入120:自测练习1Option Base 1Private Sub Form_Click()Dim i%, a(1 To 20) As Integera(1) = 1: a(2) = 1Print a(1);Print a(2);For i = 3 To 10a(i) = a(i - 1) + a(i - 2)Print a(i);Next iPrintFor i = 11 To 16a(i) = a(i - 1) + a(i - 2)Print a(i);Next iPrintFor i = 17 To 20a(i) = a(i - 1) + a(i - 2)Print a(i);Next i初始界面:运行结果界面:自测练习2Option Base 1Private Sub Form_Load()Form1.Width = 10000Form1.Height = 5000End SubPrivate Sub Command1_Click()Dim i%, j%, t%, a(1 To 4, 1 To 4) As Integer For i = 1 To 4For j = 1 To 4a(i, j) = Int(Rnd * 10) + 1Picture1.Print a(i, j);Next jPicture1.PrintNext iPicture3.Print "对角线的元素如下" For i = 1 To 4Picture3.Print a(i, i);Next iPicture3.PrintFor i = 1 To 4Picture3.Print a(i, 5 - i);Next iFor i = 1 To 4t = a(1, i)a(1, i) = a(4, i)a(4, i) = tNext iFor i = 1 To 4t = a(i, 2)a(i, 2) = a(i, 3)a(i, 3) = tNext iFor i = 1 To 4For j = 1 To 4Picture2.Print a(i, j); Next jPicture2.PrintNext iEnd Sub运行初始界面:运运行结果界面:自测练习1Sub itostr(a As Integer) Dim b%, c$a = Val(Text1.Text)While a >= 1c = Chr(a Mod 10 + 48) & c a = a \ 10WendText2.Text = c End SubPrivate Sub Command1_Click()Dim a As Integera = Val(Text1.Text)Call itostr(a)End Sub运行初始界面:运行结果界面:验证其他数字:自测练习2:Public Function area(n) As DoubleDim c#, d#, e#, s#n = Val(Text2.Text)c = (1 - 0) / nWhile e <= 1d = I * c:e = (I + 1) * cs = s + (Sin(d) + Sin(e)) * c / 2I = I + 1Wendarea = sEnd FunctionPrivate Sub Command1_Click()Dim s As DoubleCall area(n)Text1.Text = area(n)End Sub运行初始界面:运行结果:自测练习3Private Sub Form_click()n = Val(InputBox("请输入n的值"))x = Val(InputBox("请输入x的值"))Print "e的值="; es(n, x)End SubPrivate Function es(n, x)Dim a As Double, b As Double, c As Double, i As Integer a = 1: b = 1: c = 1For i = 1 To na = x * a:b = b * i:c = c + a / bNext ies = cEnd Function运行初始界面:输入数据:运行结果:自测练习4:For i = 1 To 4For j = i + 1 To 5If a(i) > a(j) Thent = a(i): a(i) = a(j): a(j) = t End IfNext jNext iFor i = 1 To 5Print a(i); " ";Next iFor i = 1 To 5If Y < a(i) Thent = a(i): a(i) = Y: Y = tEnd IfNext iFor i = 1 To 6a(6) = tNext iEnd FunctionPrivate Sub Command1_Click()Dim i#, a%(1 To 6), Y%Y = Val(InputBox("输入y的值", "输入数据")) Insertfun a%(), YPrintFor i = 1 To 6Print a(i); " ";Next iEnd Sub运行初始界面:插入数据:运行结果:自测练习1:Private Sub Command1_Click()If Ch1.Value = 1 ThenText1.Text = "报名参加羽毛球比赛"End IfIf Ch2.Value = 1 ThenText1.Text = "报名参加乒乓球比赛"End IfIf Ch1.Value = 1 And Ch2.Value = 1 ThenText1.Text = "报名参加羽毛球,乒乓球比赛" End IfEnd Sub运行初始界面:运行结果:自测练习4:Private Sub Form_Load()Label1.Alignment = 2Label1.FontSize = 24Label1.FontName = "黑体"Label1.ForeColor = &HFF&End SubPrivate Sub Option1_Click()Label1.Caption = "我是学生"End SubPrivate Sub Option2_Click()Label1.Caption = "我是教师"End SubPrivate Sub Option3_Click()Label1.Caption = "我是工人"End SubPrivate Sub Option4_Click()Label1.Caption = "我是农民"End Sub运行初始界面:运行结果:自测练习6:Private Sub Command1_Click()For i = 0 To Combo1.ListCount - 1If Combo1.List(i) = Combo1.Text Then Exit ForEnd IfNext iIf i > Combo1.ListCount - 1 Then Combo1.AddItem Combo1.TextEnd IfEnd SubPrivate Sub Command2_Click()If Combo1.ListIndex <> -1 Then Combo1.RemoveItem Combo1.ListIndex For i = 0 To Combo1.ListCount - 1If Combo1.List(i) = Combo1.Text Then Combo1.RemoveItem iEnd IfExit ForNext iEnd IfEnd SubPrivate Sub Command3_Click() Combo1.ClearEnd Sub运行初始界面:自测练习7:Private Sub Command1_Click() Timer1.Interval = 1Timer1.Enabled = TrueEnd SubPrivate Sub Form_Load() lbltemp1.FontSize = 20 lbltishi.FontSize = 20Label1.FontSize = 20Label2.FontSize = 20End SubPrivate Sub Timer1_Timer() VSbwd.Value = VSbwd.Value + 10 lbltem = VSbwd.ValueIf VSbwd >= 100 Thenlbltishi = "水开了"Timer1.Enabled = FalseEnd IfEnd Sub运行初始界面:运行结果:自测练习1:Private Sub myhelp_Click() frmAbout.ShowEnd SubPrivate Sub mymenu1_Click() Text1.Text = "百货大楼" End SubPrivate Sub mymenu2_Click() Text1.Text = "利客隆"End SubPrivate Sub mymenu3_Click() Text1.Text = "稻香村"End Sub运行初始界面:运行结果界面:自测练习2:Private Sub Dis_Click()Text1.Text = "菜单程序设计"Text1.FontSize = 20Text1.FontName = "黑体"End SubPrivate Sub Hid_Click()Text1.Visible = FalseEnd Sub运行初始界面:运行结果界面:自测练习3:Private Sub vbhelp_Click()r = MsgBox("帮助", , "程序设计题") End SubPrivate Sub Vbnew_Click()r = MsgBox("新建", , "程序设计题") End SubPrivate Sub vbopen_Click()r = MsgBox("打开", , "程序设计题") End SubPrivate Sub vbsave_Click()r = MsgBox("存盘", , "程序设计题")End Sub运行初始界面:运行结果:自测练习4:Private Sub Command1_Click()CommonDialog1.Action = 1List1.AddItem CommonDialog1.FileNameEnd Sub运行初始界面:运行结果:自测练习1:Private Sub Command1_Click()Dim a As String, n%, i%, j%Open "E:\Data.txt" For Input As #1 Input #1, an = Len(a)j = 0For i = 1 To nIf Mid(a, i, 1) = "%" Then j = j + 1 Next iClose #1Open "E:\Datares.txt" For Output As #1 Print #1, jClose #1End Sub运行初始界面:运行结果:自测练习3:Private Sub Form_Click()Dim x$Open "e:\txt2.txt" For Input As #1Do While Not EOF(1)Line Input #1, x$LoopClose #1Open "e:\txt1.txt" For Append As #1Print #1, x$Close #1End Sub运行初始界面:自测练习4Private Sub Form_load()Print " 26个英文字母"PrintPrint " a b c d e f g h i j k l m n o p q r s t u v w x y z"Print "字母个数分别为"End SubPrivate Sub Form_Click()Open "E:\Data.txt" For Output As #1文本$ = InputBox("请输入文本")n = UCase(文本$)Print #1, nClose #1Dim a%()Open "E:\Data.txt" For Output As #1 For i = 1 To Len(n)ReDim Preserve a(1 To 26)j = Asc(Mid(n, i, 1)) - 64a(j) = a(j) + 1Next iClose #1For j = LBound(a) To UBound(a)Print a(j);Next jEnd Sub。
VB实验及答案
对象名称
属性名称
Form1
Caption
Command1 Caption
Label1
Caption
Label2
Caption
Label3
Caption
Text1、Text2 Text
属性值 象限判断 判断 X= Y=
(3)编写事件代码: Private Sub Command1_Click() Dim x!, y!
Private Sub Command2_Click() Dim f!, c! c = Val(Text2.Text) f = 9 / 5 * c + 32 Text1 = Str(f)
End Sub
(4)程序的运行及保存。 4 求圆的面积及圆柱体的体积,界面如图 2-3 所示。
【步骤】 (1)设计应用程序的界面:在窗体上创建两个命令按钮 Command1 和 Command2,四个标签 Label1、Label2、Label3 和 Label4,四个文本框 Text1、Text2、Text3 和 Text4。 (2)设置对象的属性
【步骤】
( 1 ) 在 窗 体 中 创 建 一 个 标 签 Label1 、 一 个 命 令 按 钮 Command1。
(2)在属性窗口中设置对象的属性:
对象名称
属性名称
属性值
Form1
Caption
设计界面
Label1
Caption
请留意此处
Command1
Caption
单击此处
(3)在 Command1 的 Click 事件中编写程序代码:
x = Val(Text1) y = Val(Text2) If x > 0 Then
VB实验教材的实验与习题答案
实验4-11
Len(st); Ch=Lcase(ch) ; Case Else ; Mid(Char,I,1)&St
?
实验4-12
i\100 ; (i Mod 100)\10
?
习题
一、 选择题
1.C 2. C 3.A 4. D 5.A 6. B 7. B 8. D 9. B
Const g = 9.8
Dim V0 As Single, t As Single
Dim S As SingFra biblioteke V0 = InputBox("请输入V0的值:")
t = InputBox("请输入时间t的值:")
S = (1 / 2) * g * t ^ 2 + V0 * t
Randomize
a = Int(Rnd * (999 - 100 + 1) + 100)
h = Mid(CStr(a), 1, 1)
t = Mid(CStr(a), 2, 1)
n = Right(CStr(a), 1)
Label5.Caption = a & "-->" & Format(n * 100 + t * 10 + h, "000")
List1.AddItem Log(a) / Log(b)
End Sub
‘关系运算
Private Sub Command2_Click()
List1.Clear
List1.AddItem Mid("Visual Basic", 1, 12) = Right("Language Visual Basic", 12)
VB实验教材习题答案 (1)
第1章VB集成环境与VB概述一、选择题第2章常用控件与界面设计一、选择题第3章数据、表达式与简单程序设计一、选择题第4章选择分支与循环一、选择题二、填空题1.5 7 13 12 14 112. 3 1 5 3 4 13. right(a$,i)4. 45. 6-i6. 6 11 10 21 13 347. 5 14 138. Is else end select9. a*(2*i-1)*(-1)*x/(2*i+2) i+110. 0 n-111. 1 t*(-1)*x^2/((2*k-1)*(2*k)) Abs(t)>eps12. count1=count+1 count1>013. sum=0 sum+j st & k & “+”14. 9 x三、编程题1.Option ExplicitPrivate Sub Command1_Click()Dim s As String, i As Integer, ch As String * 1Dim a As Integer, b As Integer, c As Integers = Text1.TextFor i = 1 To Len(s)ch = Mid(s, i, 1)If (ch >= "0" And ch <= "9") Thena = a + 1ElseIf (ch >= "A" And ch <= "Z") Or (ch >= "a" And ch <= "z") Thenb = b + 1Elsec = c + 1End IfNextPrint "数字个数"; aPrint "字符个数"; bPrint "其他字符"; cEnd Sub2.Option ExplicitPrivate Sub Command1_Click()Dim i As Integer, n As IntegerDim a As Integer, b As Integer, c As IntegerFor i = 1 To 50n = Int(Rnd * 90 + 10)Print n;If i Mod 10 = 0 Then PrintIf n <= 40 Thena = a + 1ElseIf n <= 70 Thenb = b + 1Elsec = c + 1End IfNext iPrint "小于等于40的个数:"; aPrint "大于40小于等于70的个数:"; bPrint "大于70的个数:"; cEnd Sub3.Option ExplicitPrivate Sub Command1_Click()Dim x As SingleDim t As Long, n As Integerx = 1t = 1n = 1Do While 1 / t >= 0.0001x = x + 1 / tn = n + 1t = t * nLoopPrint xEnd Sub4.Option ExplicitPrivate Sub Command1_Click()Dim k As Integer, sum As Integer, i As Integerk = InputBox("请输入一个正整数k", "输入框")For i = 1 To Len(CStr(k))sum = sum + Mid(k, i, 1)Next iMsgBox k & "的各位数字之和" & sumEnd Sub5.Option ExplicitPrivate Sub Command1_Click()Dim i As Integer, iSum As LongFor i = 1 To 20iSum = iSum + i ^ 4NextPrint iSumEnd Sub6.Option ExplicitPrivate Sub Command1_Click()Dim a As Integer, b As IntegerDim sum1 As Integer, sum2 As LongDim i As Integer, j As IntegerFor a = 2 To 3000sum1 = 0sum2 = 0For i = 1 To a \ 2If a Mod i = 0 Then sum1 = sum1 + i Next ib = sum1For j = 1 To b \ 2If b Mod j = 0 Then sum2 = sum2 + j Next jIf sum2 = a And a < b Then Print a, bNextEnd Sub7.Private Sub Command1_Click() '打印菱形Dim i As Integer, j As IntegerClsFor i = 1 To 6 '打印菱形上边6行Print Tab(20);Print Spc(6 - i);For j = 1 To 2 * (i - 1) + 1If j = 1 Or j = 2 * (i - 1) + 1 ThenPrint "*";ElsePrint " ";End IfNext jPrintNext iFor i = 5 To 1 Step -1 '打印下半部分Print Tab(20);Print Spc(6 - i);For j = 1 To 2 * (i - 1) + 1If j = 1 Or j = 2 * (i - 1) + 1 ThenPrint "*";ElsePrint " ";End IfNext jPrintNext iEnd Sub8.Option ExplicitPrivate Sub Command1_Click()Dim i As Integer, j As Integer, iSum As IntegerPrint "连续和为1250的正整数是:"For i = 1 To 500iSum = 0For j = i To 500iSum = iSum + jIf iSum >= 1250 Then Exit ForNextIf iSum = 1250 ThenPrint i; " ~"; jEnd IfNextEnd Sub9.Option ExplicitPrivate Sub Command1_Click()Dim a As Integer, b As Integer, c As IntegerFor a = 1 To 50For b = a To 50For c = b To 50If a ^ 2 + b ^ 2 = c ^ 2 ThenPrint a, b, cEnd IfNext cNext bNext aEnd Sub第5章数组一、选择题二、填空题1.Variant2.ReDim A(N)A(1)If M < A(I) Then M = A(I)3.Int(26 * Rnd) + 65Chr(t)i + 1 To 10A(i) > A(j)4.InStr(s, ",")Right(s, Len(s) - n)s5.T – 1I + 16.k = 6 - i – jmax = m7.j = 48j = j-38.i + 1i = i + 19. 23710. 3103511.numi + 1a(j)=temp三、编程题1.Option ExplicitOption Base 1Private Sub Command1_Click()Dim a(10) As IntegerDim i As Integer, max As IntegerFor i = 1 To 10a(i) = Int(90 * Rnd) + 10Print a(i);Next iPrinti = 1max = 0Do While i <= 10If a(i) Mod 3 = 0 ThenIf a(i) > max Thenmax = a(i)End IfEnd Ifi = i + 1LoopIf max = 0 ThenPrint "无要找的数"ElsePrint max & "是最大的能被3整除的数"End IfEnd Sub2.Option ExplicitOption Base 1Private Sub Command1_Click()Dim A() As IntegerDim I As Integer, m As IntegerDim K As IntegerReDim A(10)Print "原数组:";For I = 1 To 10A(I) = IPrint A(I);Next IPrintm = InputBox("????m")K = 9 + mReDim Preserve A(K)For I = 11 To KA(I) = A(I - 10)Next IFor I = 1 To 10A(I) = A(I + m - 1)Next IPrint "平移后的数组:";For I = 1 To 10Print A(I);Next IPrintEnd Sub3.Option ExplicitOption Base 1Private Sub Command1_Click()Dim I As Integer, J As Integer, K As IntegerDim a() As Integer, n As Integer, p As Integer Dim s As String, Flag As Booleanp = 1For K = 10 To 100I = 1Do While I <= 10 And Not FlagJ = 1Do While J <= 10 And Not Flagn = I ^ 2 + J ^ 2If n = K ThenFlag = TrueReDim Preserve a(p)a(p) = Kp = p + 1s = I & Str(J) & Str(K)List1.AddItem sEnd IfJ = J + 1LoopI = I + 1LoopFlag = FalseNext KEnd Sub4.Option ExplicitPrivate Sub Command1_Click()Dim A(10) As IntegerDim B(10) As Integer, S As StringDim I As Integer, J As Integer, X As IntegerA(1) = Int(90 * Rnd) + 10S = A(1)For I = 2 To 10DoX = Int(90 * Rnd) + 10For J = 1 To I - 1If X = A(J) Then Exit ForNext JIf J = I ThenA(I) = XS = S & " " & A(I)Exit DoEnd IfLoopNext IText1.Text = SB(1) = Int(90 * Rnd) + 10S = B(1)For I = 2 To 10DoX = Int(90 * Rnd) + 10For J = 1 To I - 1If X = B(J) Then Exit ForNext JIf J = I ThenB(I) = XS = S & " " & B(I)Exit DoEnd IfLoopNext IText2.Text = SS = ""For I = 1 To 10For J = 1 To 10If A(I) = B(J) ThenS = S & " " & A(I)End IfNext JNext IIf S = "" ThenText3.Text = "没有重复"ElseText3.Text = SEnd IfEnd SubPrivate Sub Command2_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""Text1.SetFocusEnd Sub5.Option ExplicitPrivate Sub Command1_Click()Dim I As Integer, J As IntegerDim a() As Integer, K As Integer, Sum As Integer K = Val(Text1.Text)I = 1DoJ = K Mod 10ReDim Preserve a(I)a(I) = JSum = Sum + JK = K \ 10I = I + 1Loop Until K = 0Text2.Text = SumEnd Sub6.Option ExplicitPrivate Sub Command1_Click()Dim a(100, 2) As Integer, K As IntegerDim I As Integer, J As IntegerDim M As Integer, N As IntegerK = 1For I = 1 To 99For J = 1 To 99If I > J ThenM = I - JN = I + JIf Sqr(M) = Int(Sqr(M)) And Sqr(N) = Int(Sqr(N)) ThenList1.AddItem I & " " & Ja(K, 1) = Ia(K, 2) = JK = K + 1End IfEnd IfNext JNext IEnd Sub7.Option ExplicitOption Base 1Dim a(5, 5) As IntegerPrivate Sub Command1_Click() '生成数组并显示Dim i As Integer, j As IntegerPicture1.ClsPicture2.ClsPicture3.ClsRandomizeFor i = 1 To 5For j = 1 To 5a(i, j) = Int(90 * Rnd) + 10Picture1.Print a(i, j);NextPicture1.PrintNextEnd SubPrivate Sub Command2_Click()Dim i As Integer, j As Integer, max As IntegerDim b(5) As Integer, c(5) As IntegerFor i = 1 To 5max = a(i, 1)For j = 1 To 5If max < a(i, j) Thenmax = a(i, j)End Ifb(i) = maxIf max = a(i, j) Then c(i) = jNext jNext iFor i = 1 To 5Picture2.Print b(i)Picture3.Print c(i)NextEnd Sub8.Option ExplicitOption Base 1Dim a(5, 5) As IntegerPrivate Sub Command1_Click() '生成数组并显示Dim i As Integer, j As IntegerPicture1.ClsPicture2.ClsLabel3.Caption = "最大值?"Label4.Caption = "最小值?"RandomizeFor i = 1 To 5For j = 1 To 5a(i, j) = Int(90 * Rnd) + 10Picture1.Print a(i, j);NextPicture1.PrintNextEnd SubPrivate Sub Command2_Click() '交换并显示Dim i As Integer, j As Integer, t As IntegerDim maxi As Integer, mini As Integer, max As Integer, min As Integer max = 10: min = 99For i = 1 To 5For j = 1 To 5If max < a(i, j) Thenmax = a(i, j)maxi = iEnd IfIf min > a(i, j) Thenmin = a(i, j)mini = iEnd IfNextNextIf maxi <> mini ThenFor j = 1 To 5t = a(maxi, j)a(maxi, j) = a(mini, j)a(mini, j) = tNext jFor i = 1 To 5For j = 1 To 5Picture2.Print a(i, j);NextPicture2.PrintNextLabel3.Caption = "最大值" & max & "在第" & maxi & "行"Label4.Caption = "最小值" & min & "在第" & mini & "行"ElsePicture2.Print "最小值和最大值在一行"Label3.Caption = "最大值" & max & "在第" & maxi & "行"Label4.Caption = "最小值" & min & "在第" & mini & "行"End IfEnd SubPrivate Sub Form_click()Picture1.ClsPicture2.ClsLabel3.Caption = ""Label4.Caption = ""End Sub9.Option Base 1Private Sub Command1_Click()Dim i As Integer, j As Integer, n As Integer, a() As Integern = InputBox("请输入一个奇数N:")If n Mod 2 = 0 ThenMsgBox ("请重新输入奇数!")End IfReDim a(n, n)For i = 1 To nFor j = 1 To nIf i = (n + 1) / 2 And j = (n + 1) / 2 Thena(i, j) = -1ElseIf i = j Or i + j = n + 1 Thena(i, j) = 1Elsea(i, j) = 0End IfNext jFor i = 1 To nFor j = 1 To nPrint a(i, j);Next jPrintNext iEnd Sub10.Option Base 1Dim a(10) As IntegerPrivate Sub Command1_Click()Dim i As IntegerPrint "生成的数组:"RandomizeFor i = 1 To 10a(i) = Int(Rnd * 90) + 10Print a(i);NextPrintEnd SubPrivate Sub Command2_Click()Dim i As Integerx = InputBox("请输入要删除的数组元素下标:") Print "删除第" & x & "个数组元素后:"For i = x + 1 To 10a(i - 1) = a(i)NextFor i = 1 To 9Print a(i);NextEnd Sub11.Option ExplicitDim a(20) As Integer, i As IntegerPrivate Sub Command1_Click()RandomizeFor i = 1 To 20a(i) = Int(Rnd * 9) + 1Text1 = Text1 & a(i) & " "If i = 10 Then Text1 = Text1 & vbCrLf NextPrivate Sub Command2_Click()Dim j As Integer, k As Integer, b(20) As Boolean 'b(2)用来记录a(2)是否和前面的数相同,相同记为true,不再统计For i = 1 To 20k = 1If b(i) = False Then '如果b(i)=False,表示a(i)没有被统计过For j = i + 1 To 20If a(i) = a(j) Thenk = k + 1b(j) = TrueEnd IfNext jList1.AddItem a(i) & "出现次数:" & kEnd IfNextEnd SubPrivate Sub Command3_Click()Text1 = ""List1.ClearEnd Sub第6章过程一、选择题二、填空题1. 6 .2. 4 20 1013.第一行是 6 26 、第三行是-2 984.第一行10 6 、第二行 5 -55.第一行 6 5 、第三行8 76.第一行11 、第二行77.Fun(i)Fun=p8.第一行 4 、第二行2079.第一行29 、第二行28.710.J=kb( ) As Integerb( k-1) =b(k)i11.第一行gec 、第二行ge 、第四行 312.p1 = True And p2 = True 或p1 And p2= isp(i)Isp = Truem Mod i = 013.Convert(st)Len(s)"A" To "F"k = k + p * h14.isualVisualVisu15.s + an + 1x As Single, n As Integer 、p * (x + i) / ((2 * i - 1) * i * x)16.27617.Left(s, 1)Mid(s, i - 1, 1) = Mid(s, i, 1)n = 1c & CStr(n)18.chtempTrue19.val(mid(s,i,j))n as longprime=True20.A(2,2)的值是 6 ,A(3,1) 的值是8 ;A(4,2) 的值是 321.Option1(i)X22.1023.第一行7 6 ,第二行16 16 ,第三行,4524.第一行15 1 ,第二行35 3 ,第三行,50三、改错题1、Option Base 1Private Sub Command1_Click()Dim A() As Integer, I As Integer, J As Integer, Logic As Boolean Dim K As IntegerReDim A(1)A(1) = 50————————'K=1For I = 51 To 149K = 1 '位置错Logic = FalseCall Sub1(A, I, Logic)If Logic ThenK = K + 1ReDim A(K) 'ReDim Preserve A(K)A(K) = IEnd IfNext IFor I = 1 To UBound(A)Text1 = Text1 & Str$(A(I))If I Mod 5 = 0 Then Text1 = Text1 & vbCrLfNext IEnd SubPrivate Sub Sub1(A() As Integer, N As Integer, F As Boolean) Dim I As Integer, J As Integer, Ub As IntegerUb = UBound(A)For I = 1 To UbFor J = 2 To A(I)If A(I) Mod J = 0 And N Mod J = 0 ThenExit For 'Exit SubEnd IfNext JF = TrueNext IEnd Sub2、Option ExplicitOption Base 1Private Sub Command1_Click()Dim I As Integer, Flg As Boolean, S1 As Integer, S2 As IntegerDim J As Integer, K As Integer, P() As IntegerReDim P(1)P(1) = 2For I = 3 To 150 Step 2For J = 2 To Sqr(I)If I Mod J = 0 Then Exit ForNext JIf J > Sqr(I) ThenReDim Preserve P(UBound(P) + 1)P(UBound(P) + 1) = I 'P(UBound(P)) = IEnd IfNext IFor I = 80 To 125If fun(I, P, S1, S2) Then 'If fun(I, P, S1, S2)Text1 = Text1 & Str$(I) & "=" & Str(S1) & "*" & Str$(S2) & vbCrLf End IfNext IEnd SubPrivate Function fun(N As Integer, P() As Integer, S1 As Integer, S2 As Integer) As Boolean Dim I As Integer, J As IntegerFor I = 1 To UBound(P)For J = 1 To UBound(P) - 1If N = P(I) * P(J) ThenS1 = P(I)S2 = P(J)'fun = TrueExit Functionfun = True '位置错End IfNext JNext IEnd Function3、Option ExplicitPrivate Sub Get_Chess(Chess() As Integer, idx As Integer, Over As Integer) 'ByVal idx As IntegerDim Ub As Integer, Counter As Integer, K As IntegerUb = UBound(Chess)Chess(idx) = 0Counter = 1K = 0 '位置错Do Until Counter = Ub - 1Do Until K = 2idx = idx + 1If idx > Ub Then idx = 1K = K + Chess(idx)LoopChess(idx) = 0Counter = Counter + 1LoopFor Over = 1 To UbIf Chess(Over) <> 0 Then Exit ForNext OverEnd SubPrivate Sub Command1_Click()Dim Chess(32) As Integer, I As Integer, J As IntegerDim K As Integer, idx As IntegerFor I = 1 To 32For J = 1 To 32Chess(J) = 1Next JCall Get_Chess(Chess, I, K)If K = 23 ThenText1 = "从第" & Str$(I) & "号棋子开始取"Exit ForEnd IfNext IEnd Sub4、Option ExplicitPrivate Sub Form_Click()Dim S As String, Flg As BooleanDoS = InputBox("输入一个自然数")If S = "" Or Not IsNumeric(S) ThenMsgBox "请重新输入", 48 + vbOKOnlyElseExit DoEnd IfLoopjudge(S, Flg) ' Call judge(S, Flg) 或judge S, Flg If Flg ThenPrint S; "是回文数"ElsePrint S; "不是回文数"End IfEnd SubPrivate Sub judge(Ch As String, F As Boolean)Dim L As Integer, I As IntegerL = Len(Ch)F = True ' F = FalseFor I = 1 To LIf Mid$(Ch, I, 1) <> Mid$(Ch, L + 1 - I, 1) Then Exit Sub Next IF = False ' F = TrueEnd Sub四、编程题1.Private Function Prime(a As Integer) As BooleanDim i As IntegerFor i = 2 To Sqr(a)If a Mod i = 0 Then Exit FunctionNext iPrime = TrueEnd Function'方法一Private Sub Command1_Click()Dim m As Integer, i As Integerm = InputBox("请输入一个大于2 的偶数")If m <= 2 Or m Mod 2 <> 0 Then MsgBox "请输入大于2的偶数": Exit Sub If Prime(2) And Prime(m - 2) ThenPrint m & "=2 +" & m - 2ElseDoi = i + 1If Prime(2 * i + 1) And Prime(m - (2 * i + 1)) ThenPrint m & "=" & 2 * i + 1 & "+" & m - (2 * i + 1)Exit DoEnd IfLoop While 2 * i + 1 < m - (2 * i + 1)End If'方法二Private Sub Command2_Click()Dim m As Integer, i As Integer, p() As Integer, n As IntegerDim flg As Booleanm = InputBox("请输入大于2的偶数")If m <= 2 Or m Mod 2 <> 0 Then MsgBox "请输入大于2的偶数": Exit Sub ReDim p(1)p(1) = 2n = 1For i = 3 To m - 2 Step 2If Prime(i) Thenn = n + 1ReDim Preserve p(n)p(n) = iEnd IfNext iFor i = 1 To nFor j = 1 To nIf p(i) + p(j) = m ThenPrint m & "=" & p(i) & "+" & p(j)flg = TrueExit ForEnd IfNext jIf flg = True Then Exit ForNext iEnd Sub2.Private Function Fact(a As Integer) As LongIf a = 0 Or a = 1 ThenFact = 1ElseFact = a * Fact(a - 1)End IfEnd FunctionPrivate Sub Command1_Click()Dim n As Integer, m As Integer, result As Singlen = Val(Text1.Text)m = Val(Text2.Text)If n >= m Thenresult = Fact(n) / Fact(m) / Fact(n - m)Text3.Text = resultMsgBox "要求n>=m,请重新输入"Text1.Text = ""Text2.Text = ""Text1.SetFocusEnd IfEnd SubPrivate Sub Command2_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""Text1.SetFocusEnd Sub3.Private Function Istgs(n As Integer) As BooleanDim s As String, L As IntegerL = Len(CStr(n))s = CStr(n ^ 2)If Right(s, L) = n Then Istgs = TrueEnd FunctionPrivate Sub Command1_Click()Dim n As IntegerFor n = 10 To 300If Istgs(n) Then List1.AddItem n & "^2" & "=" & n ^ 2 Next nEnd SubPrivate Sub Command2_Click()EndEnd Sub4.Private Sub Command1_Click()Dim a(3, 4) As Integer, i As Integer, j As IntegerDim m As Integer, mj As IntegerRandomizeFor i = 1 To 3For j = 1 To 4a(i, j) = Int(900 * Rnd + 100)Print a(i, j);Next jPrintNext iFor i = 1 To 3m = 0Call max(a, i, m, mj)Print "第" & i & "行最大值为" & m & ",在第" & mj & "列"Next iEnd SubPrivate Sub max(a() As Integer, i As Integer, m As Integer, maxj As Integer) Dim j As Integerm = a(i, 1): maxj = 1For j = 2 To UBound(a, 2)If a(i, j) > m Thenm = a(i, j)maxj = jEnd IfNext jEnd SubPrivate Sub Command2_Click()EndEnd Sub5.Private Function Judge(n As Integer) As BooleanDim sum As Integersum = yz(n)If yz(sum) = 2 * n Then Judge = TrueEnd FunctionPrivate Function yz(n As Integer) As IntegerDim i As IntegerFor i = 1 To nIf n Mod i = 0 Then yz = yz + iNext iEnd FunctionPrivate Sub Command1_Click()Dim n As IntegerFor n = 1 To 500If Judge(n) Then Print nNext nEnd SubPrivate Sub Command2_Click()EndEnd Sub6.Private Sub Command1_Click()Dim n As Integer, j As Integer, flg As BooleanFor n = 2 To 30flg = FalseFor j = 2 To nIf pfs(j) And n Mod j = 0 Thenflg = TrueExit ForEnd IfNext jIf flg = False Then Print n;Next nEnd SubPrivate Function pfs(n As Integer) As BooleanIf Sqr(n) = Int(Sqr(n)) Then pfs = TrueEnd Function7.Private Function fxs(n As Long) As LongDim i As Integer, s As StringFor i = 1 To Len(CStr(n))s = Mid(CStr(n), i, 1) & sNext ifxs = sEnd Function'判断某数是否为回文数Private Function Hws(n As Long) As BooleanDim i As Integer, s As String, L As Integers = CStr(n): L = Len(s)For i = 1 To Len(s) / 2If Mid(s, i, 1) <> Mid(s, L + 1 - i, 1) Then Exit Function Next iHws = TrueEnd FunctionPrivate Sub Command1_Click()Dim x As Long, t As Longx = InputBox("请输入一个正整数:")t = xDo While Hws(t) = FalsePrint t; "+"; fxs(t); "="; t + fxs(t)t = t + fxs(t)LoopEnd Sub8.Private Function fxs(n As Long) As LongDim i As Integer, s As StringFor i = 1 To Len(CStr(n))s = Mid(CStr(n), i, 1) & sNext ifxs = sEnd FunctionPrivate Sub Command1_Click()Dim n As Long, t As LongFor n = 1 To 999t = fxs(n)If t ^ 2 = fxs(n ^ 2) And n Mod 10 <> 0 And n < t ThenList1.AddItem n & " " & tList2.AddItem n & "^2" & "=" & n ^ 2 & " " & t & "^2" & "=" & t ^ 2 End IfNext nEnd Sub9.Private Function fxs(n As Long) As LongDim i As Integer, s As StringFor i = 1 To Len(CStr(n))s = Mid(CStr(n), i, 1) & sNext ifxs = sEnd FunctionPrivate Function Judge(n As Integer) As BooleanDim i As Integer, L As Integer, a(9) As Integer, t As IntegerIf Sqr(n) = Int(Sqr(n)) ThenL = Len(CStr(n))For i = 1 To Lt = Mid(CStr(n), i, 1)a(t) = 1Next iFor i = 0 To 9Sum = Sum + a(i)Next iIf Sum = L - 1 Then Judge = TrueEnd IfEnd FunctionPrivate Sub Command1_Click()Dim a As IntegerFor a = 300 To 2000If Judge(a) Then List1.AddItem aNext aEnd Sub10.Private Function F(n As Integer) As BooleanDim i As IntegerFor i = 1 To Len(CStr(n))If i Mod 2 = 1 And Mid(CStr(n), i, 1) Mod 2 <> 1 Then Exit FunctionIf i Mod 2 = 0 And Mid(CStr(n), i, 1) Mod 2 <> 0 Then Exit Function Next iF = TrueEnd FunctionPrivate Sub Command1_Click()Dim a(8) As Integer, i As Integer, j As IntegerRandomizeDot = Int(900 * Rnd + 100)For j = 1 To iIf t = a(j) Then Exit ForNext jIf j = i + 1 Theni = i + 1a(i) = tList1.AddItem a(i)If F(a(i)) Then List2.AddItem a(i)End IfLoop Until i = 8End SubPrivate Sub Command2_Click()List1.ClearList2.ClearEnd SubPrivate Sub CmdEnd_Click()EndEnd Sub11.Private Function prime(a As Integer) As BooleanDim i As IntegerFor i = 2 To Sqr(a)If a Mod i = 0 Then Exit FunctionNext iprime = TrueEnd FunctionPrivate Function nx(n As Integer) As IntegerDim i As Integer, s As StringFor i = 1 To Len(CStr(n))s = Mid(CStr(n), i, 1) & sNext inx = Val(s)End FunctionPrivate Sub Command1_Click()Dim n As Integer, t As IntegerFor n = 100 To 900t = nx(n)If prime(n) And prime(t) And n < t ThenList1.AddItem "(" & n & "," & t & ")"End IfNext nEnd SubPrivate Sub Command2_Click()List1.ClearEnd Sub12.Option Base 1Dim a(4, 5) As IntegerPrivate Sub Command1_Click()Dim i As Integer, j As IntegerRandomizeFor i = 1 To 4For j = 1 To 5a(i, j) = Int(Rnd * 90 + 10)Picture1.Print a(i, j);Next jPicture1.PrintNext iEnd SubPrivate Sub Fp(a() As Integer, i As Integer, maxj As Integer, Flg As Boolean) Dim max As Integer, j As Integer, t As Integermax = a(i, 1): maxj = 1For j = 2 To UBound(a, 2)If a(i, j) > max Thenmax = a(i, j)maxj = jEnd IfNext jFor t = 1 To UBound(a, 1)If a(t, maxj) > max ThenFlg = FalseExit SubEnd IfNextFlg = TrueEnd SubPrivate Sub Command2_Click()Dim i As Integer, m As Integer, mj As Integer, f As BooleanFor i = 1 To 4f = Falsem = 0: mj = 0Call Fp(a, i, mj, f)If f = True ThenText1.Text = Text1.Text & "(" & i & "," & mj & "):" & a(i, mj) & vbCrLf End IfNext iEnd SubPrivate Sub Command3_Click()Picture1.ClsText1 = ""End Sub13.Private Sub Command1_Click()Dim a(30) As Integer, i As Integer, j As IntegerDim Flag As BooleanRandomizeDot = Int(900 * Rnd + 100)For j = 1 To iIf t = a(j) Then Exit ForNext jIf j = i + 1 Theni = i + 1a(i) = tText1.Text = Text1.Text + Str(a(i))If i Mod 10 = 0 Then Text1.Text = Text1.Text + vbCrLfIf IsDown(a(i)) ThenList1.AddItem a(i)Flag = TrueEnd IfEnd IfLoop Until i = 30If Flag = False Then List1.AddItem "无降序数"End SubPrivate Function IsDown(n As Integer) As BooleanDim i As Integer, S As StringS = CStr(n)For i = 1 To Len(S) - 1If Mid(S, i, 1) < Mid(S, i + 1, 1) Then Exit FunctionNext iIsDown = TrueEnd FunctionPrivate Sub Command2_Click()List1.ClearText1 = ""End Sub14.Option ExplicitPrivate Sub CmdFind_Click()Dim i As Integer, p As String, st As String, st1 As StringFor i = 100 To 999st = ""If csum(i) = zyz(i, st) Thenp = CStr(i)st1 = Left(p, 1) & "+" & Mid(p, 2, 1) & "+" & Right(p, 1)List1.AddItem i & ": " & st1 & "=" & Left(st, Len(st) - 1)End IfNext iIf List1.ListCount = 0 ThenList1.AddItem "无满足要求的数!"End IfEnd SubPrivate Function csum(m As Integer) As Integer '求各位数字之和Dim i As Integer, p As Stringp = CStr(m)For i = 1 To Len(p)csum = csum + Val(Mid(p, i, 1))Next iEnd FunctionPrivate Function zyz(ByVal m As Integer, st As String) As Integer '求所有质因子之和Dim i As Integeri = 2DoIf m Mod i = 0 Thenzyz = zyz + ist = st & i & "+"m = m \ iElsei = i + 1End IfLoop Until m = 1End Function15.Private Sub Command1_Click()Dim k As Integer, i As Integerk = InputBox("请输入要求的数列项数:")List1.AddItem "共输出前" & k & "项数列"For i = 0 To kList1.AddItem p(i)NextEnd SubPrivate Function p(n As Integer) As IntegerIf n = 0 Or n = 1 Or n = 2 Thenp = 1Elsep = p(n - 2) + p(n - 3)End IfEnd Function第7章文件一、选择题二、填空题1.顺序文件和随机文件2. EOF3. Write和Print4.返回或设置当前的工作目录5.5116.文件的写语句7.Append8.LOF9.关闭10.Pattern11.【1】For Input 【2】#2 【3】Not EOF(2) 12.【1】”END”【2】Text1.Text 或者Text113.【1】Input 【2】ch 【3】Len(mystr) 14.【1】Number 【2】s15.【1】For Append As #1 【2】"end" 【3】ct,nt 16.【1】For Input 【2】For Output As #2 【3】Not EOF(1) 【4】Line Input #1,str1 【5】Close #1,#2 【6】Kill “C:\old.txt 17.【1】Open "C:StuData.txt" For OutPut As #1 【2】Write 18.【1】"C:\data.txt" 【2】#1, a(i) 【3】k>1 And a(k-1)>b 【4】k = k -1三、综合题1.Option Base 1Dim arr(100) As IntegerPrivate Sub Command1_Click()Dim i As IntegerOpen "c:\in18.txt" For Input As #6For i = 1 To 100Input #6, arr(i)Next iClose #6End SubPrivate Sub Command2_Click()Dim i As IntegerText1.Text = ""Open "c:\out18.txt" For Output As #8For i = 1 To 100If arr(i) Mod 2 <> 0 ThenText1.Text = Text1.Text & Str(arr(i))Write #8, arr(i)End IfNext iClose #8End Sub2.Dim str As StringDim n As LongPrivate Sub Command1_Click()CommonDialog1.Filter = "文本文件(*.txt)|*.txt|All Files(*.*)|*.*"CommonDialog1.FilterIndex = 1CommonDialog1.Action = 1Open CommonDialog1.FileName For Input As #2n = LOF(2)str = Input(n, #2)Text1.Text = strClose #2End SubPrivate Sub Command2_Click()Dim i As IntegerFor i = 1 To Len(str)If Asc(Mid(str, i, 1)) <= Asc("Z") And Asc(Mid(str, i, 1)) >= Asc("A") Then Mid(str, i, 1) = LCase(Mid(str, i, 1))ElseIf Asc(Mid(str, i, 1)) <= Asc("z") And Asc(Mid(str, i, 1)) >= Asc("a") Then Mid(str, i, 1) = UCase(Mid(str, i, 1))End IfNext iText1.Text = strEnd SubPrivate Sub Command3_Click()Open "D:\out.txt" For Output As #3Print #3, strClose #3End Sub第8章程序调试一.选择题二.改错题1.a(i)=int(Rnd*19)+1 →a(i)=int(rnd*20)+1For l=1 to a(i)+1 →for i=2 to a(i)+1If l=a(i) →if l <> a(i)K=k+1 →k=k-1。
VB程序设计学习与实验指导书答案(包含实验答案)
VB学习与实验指导测试题参考答案第一章第二章第三章第四章第五章第六章第七章第八章第九章综合测试题一综合测试题二下篇实验教程实验2 Visual Basic 变量、函数与表达式的使用实验2-1 算术运算符的使用13178332262-2-22007-10-153 2.857143 2.85714285714286实验2-2 字符运算符的使用20071020071020172007-10-10102007-10-20出错,类型不匹配实验2-3 关系运算符的使用FalseFalseFalseFalseFalseFalseFalseTrueFalseTrue实验2-4 逻辑运算符的使用TrueTrueFalseTrueFalseFalseTrueTrueFalse5-59实验2-5 常用函数的使用3.14 3.147.389056098930651 -1 .999999998205103 4-1 1 0.70554755825 251250 0A a65 9748 688 -98 -89 -9aaa 4.5 aaa4.516 5Visua 6.0sua Basic Basic 6.0abcde EFGBasic Basic BasicVisual Basic 6.0 Basic8 8aaa dd2011-3-152011-3-15 14:35:5215320113001.731.731.7317.32E-010173%实验3 算法基础及程序控制结构实验3-1 三个数的交换A=CC=BB=TBC实验3-2 求周长和面积Const PI=3.14159262*PI*RPI*R*RPicture1.ClsFormat(L, ".00")Format(M, ".00")实验3-3 求分段函数的值x=Val(Text1.Text)y=1+Sin(x)y=Log(x)Text1.Text = ""Text2.Text = ""实验3-4 求一元二次方程的根Val(Text2.Text)Val(Text3.Text)b ^ 2 - 4 * a * c"x1=" & (-b + Sqr(delt)) / (2 * a)"x2=" & (-b - Sqr(delt)) / (2 * a)Text2.Text = ""Text3.Text = ""End实验3-5 判断素数N Mod k = 0k=NN Mod i=0k=2实验3-6 求最大公约数和最小公倍数M<NL=ML=NM Mod k = 0 And N Mod k = 0Text3.Text = kExit ForM>NL=ML=Nk Mod M = 0 And k Mod N = 0Text4.Text = kExit For实验3-7 判断升序数、降序数CStr(N)Len(S) – 1Mid(S, k, 1) >= Mid(S, k + 1, 1)k = Len(S)N = Val(Text1.Text)S = CStr(N)For k = 1 To Len(S) - 1If Mid(S, k, 1) <= Mid(S, k + 1, 1) Then Exit For Next kk = Len(S)实验3-8 判断回文数1Len(s)\2-1Mid(S, k, 1) <> Mid(S, Len(S) - k + 1, 1)k = Len(S) \ 2Mid(S, k, 1) + S1S = S1实验3-9 求级数的值Val(Text1.Text)1x ^ ns * nt / s <= 10 ^ -6Text2.Text = y实验3-10 查找数字串并求和Text1.Text = ""Text2.Text = ""List1.ClearText1.TextFalseWhile Mid(s, i, 1) >= "0" And Mid(s, i, 1) <= "9" Flag = Truek = k * 10 + Mid(s, i, 1)i = i + 1Flag = Truesum + kText2.Text = sum实验3-11 随机产生20个奇数Int((99 - 10 + 1) * Rnd) + 10a Mod 2 = 1n Mod 5 = 0Picture1.Cls实验3-12 加密解密Chr(Asc("a") + (Asc(c) - Asc("a") + 3) Mod 26)c = Chr(Asc("A") + (Asc(c) - Asc("A") + 3) Mod 26) c & s2Text2.TextLen(s2)Mid(s2, i, 1)c = Chr(Asc("a") + (Asc(c) - Asc("a") + 23) Mod 26) c = Chr(Asc("A") + (Asc(c) - Asc("A") + 23) Mod 26) c & s1s1Text1.Text = ""Text2.Text = ""实验3-13 统计单词个数Text1.TextMid(s, i, 1) <> " " And i <= Len(s)i = i + 1Mid(s, start, i - start)nText1.Text = ""List1.Clear实验4 数组的使用实验4-1 一维数组的产生及输出i = 1 To 20Int((9 - 0 + 1) * Rnd + 0)i = 1 To 20Print a(i);Printi = 1 To 20Picture1.Print a(i);If i Mod 5 = 0 Then Picture1.Printi = 1 To 20Text1.Text & Space(2) & a(i)If i Mod 5 = 0 Then Text1.Text = Text1.Text & vbCrLf v In aIf i Mod 5 = 0 Then Picture2.Print实验4-2 选手得分Int((50 - 10 + 1) * Rnd + 10) / 10i = 1 To 6sum = sum + score(i)max = score(1)min = score(1)score(i) > max Then max = score(i)score(i) < min Then min = score(i)(sum - max - min) / 4实验4-3 产生10个互不相同的整数Int((999 - 10 + 1) * Rnd + 10)t Mod 10 = 5Then Exit Forn= n + 1a(i) = tFor i = 1 To 10Print a(i);If i Mod 5 = 0 Then PrintNext i实验4-4 统计数字出现的次数IsNumeric(S) = FalseExit SubLen(S)c >= "0" And c <= "9"A(c) = A(c) + 1A(k) <> 0m = m + 1实验4-5 排序1 To 10Int((99 - 10 + 1) * Rnd + 10)Text1.Text & A(n) & " "1 To 9i + 1 To 10A(i) > A(j)T = A(j)A(j) = A(i)A(i) = T1 To 910 - iA(j) > A(j + 1)T = A(j + 1)A(j + 1) = A(j)A(j) = T1 To 10Text3.Text = Text3.Text & A(i) & " "10T = A(i)ji - 1k + 11 To 10Text4.Text = Text4.Text & A(i) & " "实验4-6 二维数组的产生及输出1 To 41 To 5Int((9 - 0 + 1) * Rnd + 0)1 To 41 To 5Print A(i, j);Print1 To 41 To 5Picture1.Print A(i, j);Picture1.Print1 To 41 To 5Text1.Text = Text1.Text & A(i, j) & " "Text1.Text = Text1.Text & vbCrLf实验4-6 查找最大和最小元素及其位置1 To 31 To 4A(i, j) = Int((99 - 10 + 1) * Rnd + 10)Picture1.Print A(i, j);Picture1.PrintA(1, 1), 1, 1A(1, 1), 1, 1A(i, j)ijA(i, j) < minA(i, j)ij"最大元素" & "A(" & maxi & "," & maxj & ")=" & max "最小元素" & "A(" & mini & "," & minj & ")=" & min实验4-7 矩阵转置Dim A() As Integer"请输入N的值"ReDim A(N, N) As IntegerFor i = 1 To NFor j = 1 To NA(i, j) = Int((99 - 10 + 1) * Rnd + 10)Text1.Text = Text1.Text & A(i, j) & " "Next jText1.Text = Text1.Text & vbCrLfNext it = A(i, j)A(i, j) = A(j, i)A(j, i) = tFor i = 1 To NFor j = 1 To NText2.Text = Text2.Text & A(i, j) & " "Next jText2.Text = Text2.Text & vbCrLfNext i实验5 过程实验5-1 孪生素数和降序素数Dim i As IntegerFor i = 2 To N - 1If N Mod i = 0 Then Exit FunctionNext iPrime = TrueDim a As IntegerDim b As Integera = N \ 10b = N Mod 10If a > b ThenDecNumber = TrueElseDecNumber = FalseEnd If10 To 100Prime(i) = True And Prime(i + 2) = TrueList2.AddItem i & "和" & i + 2DecNumber(i) = True And Prime(i) = TrueList3.AddItem i实验5-2 求多项式和k = 1a = f(x, k)S + ak = k + 1Single As SingleDim i As Integer, a As Singlea = (x + 1) / xFor i = 2 To ka = a * (x + i) / ((2 * i - 1) * x)Next ia实验5-3 进制转换Asc(C) - Asc("A") + 10Left(S, k - 1)Mid(S, k + 1)Change(Mid(S2, i, 1)) * N ^ (0 - i)T1 + T2Tran(8, S)Tran(16, S)Not (C >= "0" And C <= "7" Or C >= "A" And C <= "F" Or C = ".")实验5-4 Armstrong数i As Long, a As Long, b As LongCombo1.Text实验5-5Option Base 1Dim a(5) As IntegerDim b(5) As Integerb(i) = i * i + 1Text2.Text = Text2.Text & b(i) & " "1 To 51 To 5Gcd(a(i), b(j)) = 1Gcd = KExit For实验5-6Create(a)Output(a)Sort(a)Output(a)GetMaxMin(a, MaxData, MinData)MaxDataMinDataAverage(a)Int((99 - 10 + 1) * Rnd + 10)1 To UBound(a)a(i);a(i) > a(j)t = a(j)a(j) = a(i)a(i) = t2 To UBound(a)a(i) > MM = a(i)a(i) < NN = a(i)s = s + a(i)Average = s / UBound(a)实验6 界面设计实验6-1 用户登陆MsgBox "请登录!"PassWordInput=TxtPassW.TextUserIdInput=UserId And PassWordInput=PassWordCmdReset_Click实验6-2 学籍登记OptXb(0).Value = TrueList1.AddItem Space(4) & xh & Space(6) & xm & Space(6) & xb & Space(12) & xy & Space(16) & zy & Space(4)List1.RemoveItem List1.ListIndex实验6-3 字体格式设置Select Case OpFontCheck2.Value = 1OpColor = IndexOpFont = Index实验6-4 兴趣调查List1.AddItem ItemEndSelect Case IndexItem = Text1.Text实验6-5 调色板。
VB程序设计教程实验指导与习题解答上机答案
自测1程序代码Private Sub Command1_Click() = + 3End SubPrivate Sub Command2_Click() = TrueEnd SubPrivate Sub Command3_Click() = TrueEnd SubPrivate Sub Command4_Click() = 10= False= FalseEnd Sub初始窗口:单机放大之后窗口:单机下划线之后窗口:单击加粗之后窗口:单击还原之后窗口:自测2程序代码Private Sub Command1_Click() Label1 = "visual basic"Text1 = "程序设计题"End SubPrivate Sub Command2_Click() Text1 = "visual basic"Label1 = "程序设计题"End Sub初始窗口:单击显示之后窗口:单击交换之后的窗口:自测题3Private Sub Command1_Click() = *End SubPrivate Sub Command2_Click() = + 30= + 20= 1End Sub初始窗口:单击缩小两倍之后的窗口:单击向右下角移动之后的窗口:自测题4程序代码Private Sub Command1_Click() = "VB学习"Print "简单的VB程序设计" End SubPrivate Sub Command2_Click() ClsEnd SubPrivate Sub Command3_Click() EndEnd SubPrivate Sub Command3_Click() EndEnd Sub初始化窗口:单击显示之后的窗口:单击清除之后的窗口:单击退出之后的窗口:自测题5程序代码Private Sub Command1_Click() = ""= ""End SubPrivate Sub Command2_Click() = Val + ValEnd SubPrivate Sub Command3_Click() EndEnd Sub初始化窗口:单击运算之后窗口:单击清除之后的窗口:单击退出之后的窗口:自测练习1Private Sub Command1_Click() Dim a$a == Left(a, 2)End SubPrivate Sub Command2_Click() a == Right(a, 2)End SubPrivate Sub Command3_Click()= &End Sub初始窗口界面输入字符串截取前两个字符截取后两个字符字符串连接自测练习2Private Sub Form_Click()Dim a%, b%, c%, d%, e%, f%, g%, h%, i%, j%, k%, l% a = 7349e = a Mod 10 '个位d = (a \ 10) Mod 10 '十位c = (a \ 100) Mod 10 '百位b = a \ 1000 '千位i = (e + 7) Mod 10 '个位h = (d + 7) Mod 10 '十位g = (c + 7) Mod 10 '百位f = (b + 7) Mod 10 '千位j = ii = f '交换后的个位f = j '交换后的千位k = hh = g '交换后的十位g = k '交换后的百位l = f * 1000 + g * 100 + h * 10 + i= FalsePrint "加密前的4位整数是7439"; (Chr(10)); "加密后的结果是"; l End Sub初始界面单击窗体运行后的界面自测练习1Private Sub Form_Click()Dim a%, b%, c%, d%, e%, f!a = Val(InputBox("输入第一个数", "输入一个数", 8))b = Val(InputBox("输入第一个数", "输入一个数", 7))c = a + bd = a - be = a * bf = a / bf = Fix(f * 100 + / 100MsgBox "x+y=" & c & Chr(10) & "x-y=" & d & Chr(10) & "x*y=" & e & Chr(10) & "x/y=" & f, , "输出的结果"End Sub自测练习2Private Sub Form_Click()Dim a%, b%, c%, d%, e%, f!a = Val(InputBox("输入第一个数的值"))b = Val(InputBox("输入第二个数的值"))c = Val(InputBox("输入第三个数的值"))d = Val(InputBox("输入第四个数的值"))e = a + b + c + df = e / 4Print "和="; e Print "平均值="; f End Sub自测练习3Private Sub Form_Click()Dim h%, f%, x%, y%h = Val(InputBox("输入总头数")) f = Val(InputBox("输入总脚数")) x = (4 * h - f) / 2y = (f - 2 * h) / 2Print "笼中鸡的头数为"; x; "只" Print "笼中兔的头数为"; y; "只"End Sub自测练习1:Private Sub Form_Click() Dim a%, b%, c%a = Val(InputBox("请输入第一条边", "边长"))b = Val(InputBox("请输入第二条边", "边长"))c = Val(InputBox("请输入第三条边", "边长"))If a + b > c And a + c > b And b + c > a ThenIf a * a + b * b = c * c Or a * a + c * c = b * b Or b * b = c * c = a * a Then Print "直角"ElseIf a = b And b = c ThenPrint "等边三角形"ElseIf a = b Or a = c Or b = c ThenPrint "等腰三角形"ElsePrint "一般三角形"End IfElsePrint "不是三角形"End IfEnd Sub不是三角形运行结果:初始窗口:输入三条边:运行结果:直角三角形运行结果:等边三角形运行结果如下:等腰三角形:一般三角形自测练习2:Private Sub Form_Click()Dim a%, b!a = Val(InputBox("请输入"))If a Mod 2 = 0 And a Mod 3 = 0 And a Mod 5 = 0 Then b = Sqr(a)Print a, bElseEndEnd IfEnd Sub初始化窗口:输入一个数:运行结果:自测练习3Private Sub Command1_Click()Dim a%, b%a = ValSelect Case a > 0Case a < 20MsgBox "行李费为元/kg", , "行李费"Case a >= 20 And a < 50MsgBox "行李费为元/kg", , "行李费"Case a >= 50 And a < 100MsgBox "行李费为元/kg", , "行李费"Case Elseb = * 100 + (a - 100) * : MsgBox "行李费为" & b & "元", , "行李费" End SelectEnd Sub初始窗口:输入10:输入25:输入55:输入120:自测练习1Option Base 1Private Sub Form_Click() Dim i%, a(1 To 20) As Integera(1) = 1: a(2) = 1 Print a(1);Print a(2);For i = 3 To 10a(i) = a(i - 1) + a(i - 2) Print a(i);Next iPrintFor i = 11 To 16a(i) = a(i - 1) + a(i - 2) Print a(i);Next iPrintFor i = 17 To 20a(i) = a(i - 1) + a(i - 2) Print a(i);Next i初始界面:运行结果界面:自测练习2Option Base 1Private Sub Form_Load() = 10000= 5000End SubPrivate Sub Command1_Click()Dim i%, j%, t%, a(1 To 4, 1 To 4) As Integer For i = 1 To 4For j = 1 To 4a(i, j) = Int(Rnd * 10) + 1a(i, j);Next jNext i"对角线的元素如下"For i = 1 To 4a(i, i);Next iFor i = 1 To 4a(i, 5 - i);Next iFor i = 1 To 4t = a(1, i)a(1, i) = a(4, i)a(4, i) = tNext iFor i = 1 To 4t = a(i, 2)a(i, 2) = a(i, 3)a(i, 3) = tNext iFor i = 1 To 4 For j = 1 To 4a(i, j);Next jNext iEnd Sub运行初始界面:运运行结果界面:自测练习1Sub itostr(a As Integer) Dim b%, c$a = ValWhile a >= 1c = Chr(a Mod 10 + 48) & ca = a \ 10Wend= cEnd SubPrivate Sub Command1_Click() Dim a As Integera = ValCall itostr(a)End Sub运行初始界面:运行结果界面:验证其他数字:自测练习2:Public Function area(n) As Double Dim c#, d#, e#, s#n = Valc = (1 - 0) / nWhile e <= 1d = I * c:e = (I + 1) * cs = s + (Sin(d) + Sin(e)) * c / 2I = I + 1Wendarea = sEnd FunctionPrivate Sub Command1_Click() Dim s As DoubleCall area(n)= area(n)End Sub运行初始界面:运行结果:自测练习3Private Sub Form_click()n = Val(InputBox("请输入n的值"))x = Val(InputBox("请输入x的值"))Print "e的值="; es(n, x)End SubPrivate Function es(n, x)Dim a As Double, b As Double, c As Double, i As Integer a = 1: b = 1: c = 1For i = 1 To na = x * a:b = b * i:c = c + a / bNext ies = cEnd Function运行初始界面:输入数据:运行结果:自测练习4:For i = 1 To 4For j = i + 1 To 5If a(i) > a(j) Thent = a(i): a(i) = a(j): a(j) = tEnd IfNext jNext iFor i = 1 To 5Print a(i); " ";Next iFor i = 1 To 5If Y < a(i) Thent = a(i): a(i) = Y: Y = tEnd IfNext iFor i = 1 To 6a(6) = tNext iEnd FunctionPrivate Sub Command1_Click()Dim i#, a%(1 To 6), Y%Y = Val(InputBox("输入y的值", "输入数据")) Insertfun a%(), YPrintFor i = 1 To 6Print a(i); " "; Next iEnd Sub运行初始界面:插入数据:运行结果:蓝志鹏资源1102 实验8自测练习1:Private Sub Command1_Click()If = 1 Then= "报名参加羽毛球比赛"End IfIf = 1 Then= "报名参加乒乓球比赛"End IfIf = 1 And = 1 Then= "报名参加羽毛球,乒乓球比赛" End IfEnd Sub运行初始界面:运行结果:自测练习4:Private Sub Form_Load() = 2= 24= "黑体"= &HFF&End SubPrivate Sub Option1_Click() = "我是学生"End SubPrivate Sub Option2_Click() = "我是教师"End SubPrivate Sub Option3_Click() = "我是工人"End SubPrivate Sub Option4_Click() = "我是农民"End Sub运行初始界面:运行结果:。
VB实验指导书-测试题答案
营销1042第1章测试题答案一、AABD第2章测试题答案一、BCDACACC二、1.Gotfocus2.Lostfocus3.Setfocus4.Style,15.S(165)6.Vbp7. 18. ScrollBars三、1.答:Private Sub Form_Click()Form1.BackColor = vbBlue End SubPrivate Sub Form_DblClick() Form1.BackColor = vbRed End Sub2.答:(1)若在设计状态完成:(2)若在运行状态完成:编写窗体的Load事件过程如下:Private Sub Form_Load()Form1.BackColor = vbWhiteLabel1.Caption = "欢迎使用VB6.0!"Label1.ForeColor = vbYellowLabel1.BackColor = vbBlueLabel1.FontName = "黑体"Label1.FontItalic = TrueLabel1.FontSize = 20End Sub第3章测试题答案一、BBDBCADA二、1.True ”cde”2.”bcd”-123.True ”abc123xy”4.A*exp(-2*t)*sin(50*t+ 3) 5.4/3*3.1416*r^3 6.Long & 7.Double # 8.关系逻辑第4章测试题答案一、BBBAB ADBDA ADBAC二、1.判断奇偶数InputBox("输入一个整数")If a Mod 2 = 1 ThenElseMsgBox a & "是偶数"2.计算Y值Val(Text1.Text)x > 100 Thenx > 0 ThenElse3.购物优惠xVB实验指导书测试题答案Is > 5000 Is > 3000 Is > 2000 Is > 1000 Case Else 4.1+2+。
VB实验书答案
第1章一、选择题1.D 2.C 3.C 4.C 5.B 6.B7.C 8.A 9.D 10.D 11.B 12.A13.D 14.C 15.B 16.D 17.D 18.D19.C 20.A 21.C 22.B 23.B 24.C 25.C 26.C 27.C 28.B 29.B 30.B 二、填空题1.工程2.(1)程序和数据(2)属性3.(1)对象(2)事件4.“按字母顺序”5.(1)窗体(2)控件(3)菜单6.(1)对象属性(2)事件过程7.多8.标准模块9.视图10.对象查看按钮11.窗体布局12.Alt+Q第2章一、选择题1.D 2.B 3.A 4.A 5.D 6.A 7.B 8.C 9.C 10.A 11.B 12.B 13.B 14.B 15.B 16.C 17.A 18.A 19.A 20.B 21.C 22.C 23.A 24.C 25.A 26.C 27.B 28.C 29.D 30.D二、填空题1.(1)Print (2)0,02.(1)左键(2)右键3.(1)窗体(2)Font4.(1)1 (2)MDI父窗体5.Moveable6.(1)在属性窗口中设置(2)在程序代码中设置7.BackColor8.(1)Name (2)Caption9.(1)Print (2)Cls10.工程11.Hide12.Unload13..frm14.工程15.MaxButton第3章一、选择题1.D 2.D 3.A 4.D 5.B 6.B 7.C 8.B9.B 10.C 11.C 12.A 13.D 14.D 15.D 16.A17.B 18.D 19.B 20.C 21.C 22.B 23.D 24.A25.B 26.D 27.D 28.C 29.B 30.C 31.B 32.D33.A 34.B 35.B 36.C 37.D 38.C 39.A 40.C41.A 42.D 43.C 44.B 45.B 46.A47.B 48.D49.B 50.C 51.C 52.B 53.C 54.A 55.A 56.B二、填空题1.(1)窗体(2)图片框(3)Clear2.周期性地自动引发事件3.(1)Enabled (2)Locked4.TabStop5.Name和Caption(或者Name和Text)6.Timer7.Scroll和Change8.(1)0(2)−19.(1)Hide(2)Show10.(1)List(2)Selected11.ASCII码12.(1)Shift (2)Ctrl (3)Alt13.(1)DragMode (2)1 (3)DragMode (4)014.(1)MousePointer (2)99 (3)MouseIcon15.Combo1.List(Combo1.ListIndex)16.Change17.(1)密码验证(2)请输入密码:(3)* (4)验证18.(1)Unload (2)Show19.(1)BorderStyle (2)Shape20.(1)Chk1.Value(2)Text3.Passwordchar = "" (3)Text2.Text 21.(1)选择(2)性别(3)False (4)True22.Pic1.Picture=loadpicture("D:\Pic\Fishing.bmp")23.(1)KeyAscii=13 (2)a<=100(3)Text2.SetFocus (4)Len(Trim(Text1.Text))第4章一、选择题1.B 2.A 3.C 4.C 5.A 6.C 7.A 8.B 9.D 10.B 11.D 12.B 13.A 14.A 15.A 16.A 17.B 18.D 19.B 20.B21.C 22.A 23.C 24.B 25.D 26.C 27.C 28.B 29.A 30.D31.D 32.B 33.A 34.A 35.A 36.D 37.B 38.D 39.A 40.D41.B 42.B 43.D 44.C 45.A 46.D 47.D 48.D 49.A二、填空题1.(1)123 (2)567(3)889 (4)12300(5)02.(1)255 (2)冒号“:”(3)续行符“_”(空格和下划线)3.x>=-5 And x <=54.(1)(X+Y)<10 And (X−Y)>0(2)X*Y>0 And X=Int(X)And Int(Y)=Y(3)X*Y=0 And X+Y<>05.A<>0 And B*B –4*A*C>=06.(1)8888.30(2)628(3)0.67(4)0.57(5)hello(6)THIS IS A GOOD IDEA7.x+y<=8And x−y>88.x <100 And x >=09.x<=−5 or x >=510.6~1011.(1)(x^3-y^3)/(y*(sin(x))^3+7*log(y))(2)Log(y+cos(x)^2)(3)(a^(b*c)+c^(a*b))^(1/3)(4)abs((exp(x)+sin(x)^3)/(x*(x−y)))(5)log((exp(x*y)+abs(tan(z)^(−1)+cos(x)^3))/(x+y+z))12.(1)False(2)False(3)False13.(1)"10"(2)"输入整数"(3)"输入数据:10" (4)"输入的数据是:"第5章一、选择题1.A 2.B 3.D 4.C 5.C 6.C/D 7.C 8.D9.D 10.C 11.B 12.B 13.C 14.C 15.C 16.B 17.B 18.D 19.B 20.D 21.B 22.B 23.D 24.C 25.D 26.B 27.B 28.C 29.C 30.B 31.C 32.D 33.A 34.D 35.D 36.B 37.D 38.D 39.A 40.B 41.C 42.B 43.A 44.A 45.B 46.D 47.B 48.A 49.B 50.C 51.B 52.C 53.C 54.A 55.B 56.C 57.C 58.D 59.C 60.C 61.C 62.B 63.C 64.C 65.D 66.D 67.A 68.B 69.B二、填空题1. −12. −10Trur−613. 6 12312804. BASIC5. (1)6 (2)14 (3)7 (4)13(5)8 (6)3 (7)9 (8)16. (1)Spc(4)(2)Format(Sqr(a),"0.000")7. 3 −38. false9. * *0* *10. (1)a>0 And b>0 And c >0 (2)a<0 And b <0 And c<011. (1)c = Val(InputBox("请输入第三个数"))(2)b > a (3)b < a12. (1)Select Case x (2)Case Else13. (1)Text1 (2)Text1 (3)Form214. (1)Is (2)Else (3)End Select15. (1)Timer1.Enabled (2)Shape2.Top (3)Top (4)Shape2.Left16. 2117. (1)3 (2)−1818. (1)5.6 (2)519. (1)Aa (2)AaBbCc20. 2821.(1)Happy new year! (2)222.(1)For i = 1 To 5000 (2)i Mod 10 = 023.(1)d = d1 * 1000 + d2 * 100 + d3*10 + d4 (2)d = i * 924.(1)s = s + fz / fm (2)fm = fm + t25.(1)Exit Do (2)Right(Str(i),1)26.(1)Int(Rnd * 9 + 1)(2)Int(Rnd * 6 + 5)(3)j = j * 10 + a (4)If i < n Then Print j;"+";Else Print j;27.(1)n = n \ m (2)m = m + 128. If s > Max Then Max = s29.(1)c To 50 (2)b To 100 (3)1 /(a ^ 2)+ 1 /(b ^ 2)= 1 /(c ^ 2)第6章一、选择题1.A 2.C 3.D 4.C 5.A 6.B 7.C 8.C 9.B 10.C二、填空题1.(1)顺序结构(2)选择结构(3)循环结构2.(1)有穷性(2)确定性(3)有零个或多个输入(4)有一个或多个输出(5)有效性3.(1)自顶向下(2)逐步细化(3)模块化设计(4)结构化编码4.(1)伪代码(2)流程图5.模块化第7章一、选择题1.D 2.C 3.D 4.C 5.D 6.C 7.C 8.A9.D 10.C 11.B 12.D 13.B 14.B 15.B 16.B17.C 18.C 19.C 20.D 21.D 22.A 23.A 24.C25.C 26.D 27.D 28.A 29.C 30.A 31.D 32.D二、填空题1.(1)2 (2)6 (3)1 (4)2 (5)−1 (6)1 2.Variant(或变体型)3.454.(1)2 5 (2)3 65.1 2 1 4 46.0 20 25 30 35 407.−1 –2 –3 –4 –50 –1 –2 –3 –41 0 –1 –2 –32 1 0 –1 –23 2 1 0 –14 3 2 1 0s=−158.0 0 0 0 0 12 14 16 18 209.1 2 3 4 5 12 14 16 18 2010.(1)100 (2)10 (3)10 (4)a((I−1)*10+j)11.(1)Int(Rnd * 1000)(2)arr(i)> Max (3)arr(i)< Min 12.(1)preserve a(n)(2)a(I+1)=a(I)(3)a(I)=m (4)a(I+1)=m13.(1)I,J (2)I,I (3)I,5−I14.(1)a(i)= a(i − 1)(2)a(LBound(a))= j1 (3)k = j15.(1)c(2)<"A" or c(2)> "Z" (2)"Z" (3)"A"(4)keyAscii−1(5)keyAscii+116.(1)t = n (2)i To t – 1 (3)i = i + 1(4)b(i)(5)t = t − 117.(1)Redim A(n)(2)P>n or P <1 (3)P+1 (4)D 18.(1)int(Rnd*99+1)(2)In arr (3)x>50 and x <90(4)sum+x (5)x19.(1)Redim a(n,n)(2)1 to n (3)a(j,k)=i (4)Print 20.(1)7 (2)1 (3)16 (4)10 (5)5第8章一、选择题1.D 2.A 3.A 4.B 5.B 6.D 7.D 8.C 9.D 10.A11.A 12.A 13.C 14.D 15.D 16.C 17.D 18.D 19.C 20.A21.A 22.B 23.B 24.A 25.B 26.C 27.D 28.B 29.D 30.C二、填空题1.(1)4 (2)8 (3)162.1 3 14 3 109 27 93.(1)12 (2)18 (3)36 12 18 (4)36 36 124.(1)8 −2 (2)6 −25.(1)15 (2)36 (3)266.(1)34 (2)26 (3)87.3 5 7 9 58.(1)01 05 02 (2)08 (3)039.(1)10 6 (2)5 4 (3)10 −6 10.(1)17 (2)178 (3)17811.3 3 41 3 10 0 11 0 012.1 62 113 1613.(1)11 (2)61 (3)13614.(1)asicB (2)icBas15.(1)1 1 2 (2)1 3 2 (3)1 2 216.(1)Flag或Flag=True (2)Cstr(n)或Trim(Str(n))(3)Mid(x,i,1)< Mid(x,i + 1,1)17.(1)n = i * i(2)List1.AddItem(CStr(n)+ "=" + CStr(i)+ "*" + CStr(i))(3)ByVal n As Long(4)a(n Mod 10)= 1(5)If js = 2 Then Verify = True18.(1)L = 3 − Len(a)Mod 3 (2)n = Len(a)(3)c = c & Zh(b)(4)n = n + Val(Mid(s,p,1))* 2 ^ i 19.(1)Str(n)& "=" (2)P(i)+ P(j)+ P(k)= n (3)Exit Sub (4)idx = idx + 120.(1)n Mod 2 = 1 And n > 1 (2)s = n & "*3+1"(3)Exit Sub (4)Call Yz(n)第9章一、选择题1.D 2.B 3.B 4.C 5.D 6.C 7.C 8.C 9.C 10.B 11.D 12.B 13.D 14.B 15.B 16.B 17.A 18.B 19.C 20.A 21.A 22.A 23.C 24.B 25.B 26.B 27.C 28.C 29.C 30.B 31.C 32.A 33.A 34.D 35.B 36.C 37.A二、填空题1.Put2.Len3.Append4.Lof5.返回一个可供Open语句使用的文件号6.(1)Open "d:\data1.txt" For Random As #1 Len = Len(s)(2)Put #1,,s7.(1)Input (2)Output(3)0 (4)Close #1,#28.(1)For Append As #1 (2)For Input As #2(3)#1,s第10章一、选择题1.A 2.A 3.C 4.A 5.B 6.B 7.D 8.C9.C 10.C 11.A 12.C 13.D 14.D 15.B 16.A17.D 18.B 19.B 20.D 21.A 22.B 23.B 24.B25.D 26.B 27.C 28.C 29.B 30.C二、填空题1.(1)&(2)Alt (3)−2.菜单项显示区3.“→”按钮4.弹出式菜单5.调整菜单项顺序6.(1)Caption (2)Name (3)Index (4)Checked(5)Enabled (6)Visible7.(1)PopupMenu (2)MouseDown8.Ctrl+E9.(1)Height(2)Width10.(1)Microsoft Rich TextBox Control 6.0 (2)64K11.不可见的12.“部件”13.(1)DialogTitle (2)Filter (3)InitDir(4)ShowOpen或Action=1 14.StatusBar15.(1)不能(2)ToolBar。
VB实验任务5答案
实验任务5课程名称:程序设计基础VB实验名称——实验五Visual Basic程序设计基础(1)一、实验目的:1.掌握变量的定义和赋值2.掌握各种类型的数据的使用3.掌握各种运算表达式的值和使用二、实验内容(包括实验要求(题目)、实验步骤、程序清单、运行情况):实验1(1) 请分别在窗体的单击事件过程中声明定义如下变量,记录错误类型,并分析出错原因,将出错的变量名进行修改, 使其不再出错。
P59Visual Basic代码中要声明和命名一些元素(变量、常量、数据类型、过程等),命名时必须遵循以下规则:●必须以字母或汉字开头,由字母、汉字、数字或下划线组成。
●字符必须并排书写,不能出现上下标形式。
●长度小于等于255个字符。
●不可以是系统关键字。
●不可以包含空格、西文标点符号和类型说明符%、&、!、#、@、$。
●在作用域范围内必须唯一。
Private Sub Form_Click()Dim 5Fg As Integer’错在数字开头,修正为FgDim L*og As Long’错在内部包含*,修正为LogDim s-ig As Single’错在内部包含-,修正为sigDim dob_ As Double‘正确Dim _Name As string ’错在_开头,修正为Name_Dim bln@Frag As Boolean’错在内部包含@,修正为blnFragDim do As Date ’错在是系统关键字,修正为dEnd Sub,并分析出错原因)运行时,单击窗体会出现“溢出错误”的提示;分析出错原因:32768超出了Integer变量Fg的表示范围①32768(或-32768、-32769)——对Fg整型变量赋值32768或-32769,运行时,单击窗体会出现“溢出错误”的提示;分析出错原因:32768和-32769超出了Integer变量Fg的表示范围②32768(或-32768、-32769) ——对Log长整型变量赋值,运行时,单击窗体会正常显示接收的值;分析原因:32768(或-32768、-32769)都没有超出Long长整型变量Log的表示范围③1234567.12345678(或123456789.123、1.2345678)——对sig单精度变量赋值1234567.12345678,运行时,单击窗体会显示1234567;分析原因:在Visual Basic中规定单精度浮点数精度即有效位数为7位,单精度型和双精度型常量的小数形式若超出有效位数,进行小数部分的截取;对sig单精度变量赋值123456789.123,运行时,单击窗体会显示1.234568E+08;分析原因:在Visual Basic中规定单精度浮点数精度即有效位数为7位,若整数部分超出有效位数,自动转为指数形式表示;对sig单精度变量赋值1.2345678,运行时,单击窗体会显示1.234568;分析原因:在Visual Basic中规定单精度浮点数精度即有效位数为7位,单精度型和双精度型常量的小数形式若超出有效位数,进行小数部分的截取④1234567.12345678(或123456789.123、1.2345678)——对dob_双精度变量赋值,运行时,单击窗体会正常显示接收的值;分析原因:在Visual Basic中规定双精度浮点数精度为15~16位。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
VB实验指导书答案
P10 第一章
1. CAACD ABCCB
2.(1)视图工具箱
(2)代码窗体设计
(3)对象事件驱动
(4)工程
(5)中断
P21 第二章
1. CBDCD CCCDA DBCBA BDACB BCADA C
2.(1)事件
(2)Shift Ctrl
(3)工具选项编辑器
(4)窗体font
(5)Selstart
(6)强制显式声明变量
(7)类
P35 第三章
1. CBAAA BCDAD ABBBC ADDBD
2.(1)integer (2)‟‟‟‟(3)text
(4)a=0 or b=0 (5)(x+y)*sin(30*3.14/180)
(6)int(rnd*100+1) (7)# (8)0
(9)int(rnd*30+70) (10) CDEF
P53 第四章
1. BCADC CABCA AADDC BCABB
2.(1)3 (2)X mod 5 x (3)randomize (4)9 j mod 3=0 (5)66 (6)5
(7)顺序分支(或选择)循环(8)33 (9)4 8 4 (10) 退出子过程(11)1 (12)提示信息标题默认值
第6章过程
一、单选题
1.B
2.B
3.B
4.A(更正:选项④应该是Private Function F1(x As Integer) As Integer)
5.D
6.C
7.C
8.B
9.C
10.C
11.A
12.A
13.D
14.D
15.C
16.B
17.C
18.A
19.C
20.B
二、填空题
1. 形式,实际
2. 地址,值
3. SS=t
4. sq(x As Integer),Function
5. V al(t.Text)
6. 30,70
7. 5
8. tmpLabel1.Caption = tmpCombo.Text
9. 30
10. nAA N, X ,N1,nT1 * X1
11. Dim F As Double,i,Dim nfactor As Double,F = nfactor
第七章单选题
1. C
2. C
3. D
4. D
5. B
6. C
7. A
8. B
9. A
10. D
11. B
12. B
13. A
14. C
15. C
16. D
17. B
18. A
19. C
20. A
21. A
22. B
23. D
24. C
25. C
26. B
27. D
28. A
29. B
30. A
31. D
32. C 33. D
34. D
35. A
36. A
37. A
38. D
39. B
40. B
41. B
42. B
43. C
44. C
45. C
46. B
47. B
48. C
49. C
50. A
第8章界面设计
一、单选题
1.D
2.D
3.D
4.C
5.C
6.D
7.A
8.B
9.B
10.A
11.B
12.B
13.D
14.B
15.B
16.D
17.A
18.C
19.C
20.B
21.A
22.A
23.A
24.C
25.B
26.C
27.B
28.C
29.D
30.A
31.A
32.B
33.A
34.C
35.B
36.A
37.B
二、填空题
1. 菜单对象
2. 5
3. 连字符
4. 快捷键
5. 工具
6. PopupMenu
7. &,Click
8. Enabled
9. 窗体
10. 模式,无模式
11. Action
12. CommonDialog1.FileName
13. cdlCCRGBInit
14. Unload,Show
15. 所在窗体的名称
16. 打开
17. V isible
18. 当前
19. 255
20. Show 21. Load
22. Sub Main,窗体
23. 标题2
VB实验指导书9-10章答案P161 第9章
1. CCBCA DBBDB BBBCAB
2.
(1)20
(2)FreeFile
(3)Put
(4)Print Write
(5)Input Output Append Random Binary
(6)2号文件的长度文件结束标志
(7)Get
(8)Append
(9)OutPut
(10)For Input As #1
For Output As #2
P175 第10章
1. ABADC BDAAC CCBAB DD
2.
(1)Microsoft ADO Data Control 6.0
(2)True False
(3)数据绑定
(4)OLE DB
(5)记录字段
(6)第1条记录上
(7)为空
(8)Adodc1.RecordSet.Fields(“姓名”)=Name
(9)Do While not Adodc1.RecordSet.EOF
(10)RecordCount
(11)DataSource Adodc1 DataField
(12)adCmdUnknown 或adCmdText
(13)”Select * From 基本情况Where 姓名=‟”& Text1 & “…”
(14)Refresh。