VB程序设计教程(第3版)课后实验答案.doc
《VB程序设计教程(第3版)课后实验答案.doc》由会员分享,可在线阅读,更多相关《VB程序设计教程(第3版)课后实验答案.doc(37页珍藏版)》请在三一办公上搜索。
1、实验AA1Private Sub Command1_Click() Label3 = Text1End SubA2Private Sub Form_Load() Timer1.Interval = 0End SubPrivate Sub Command1_Click() 自动 Timer1.Interval = 200End SubPrivate Sub Command2_Click() 手动 Timer1.Interval = 0 Call MyMoveEnd SubPrivate Sub Timer1_Timer() Call MyMoveEnd SubSub MyMove() Label
2、1.Move Label1.Left - 50 If Label1.Left 0 Then Label1.Left = Form1.WidthEnd SubA3Private Sub Form_Click() Text1 = Val(Text1) + 1End SubPrivate Sub Form_Load() Text1 = 0End SubA4Private Sub Form_Click() Caption = 单击窗体,改变图片 Picture = LoadPicture(App.Path + n_015.bmp) Print 欢迎使用VBEnd SubPrivate Sub Form
3、_DblClick() Cls Caption = 双击窗体,卸去图片 Picture = LoadPicture() End SubPrivate Sub Form_Load() Caption = 装入窗体 Picture = LoadPicture(App.Path + n_016.bmp) Print 装入图End SubPrivate Sub Form_Resize() 该事件的作用窗体始终与图一样大 Caption = 窗体大小不变 Form1.Width = 260 * 16 260是Tongji-2.bmp图的宽度,象素单位 Form1.Height = 260 * 16 +
4、200 260是图的高度,象素单位,200是窗体的标题栏高度End SubA5Sub Command1_Click() Text1.FontName = 隶书 Text1.FontSize = 25End SubSub Command2_Click() Text2.Text = Text1.SelText Text2.FontName = Text1.FontName Text2.FontSize = Text1.FontSizeEnd Sub实验BB1Private Sub Command1_Click() Text2 = Format(5 / 9 * (Val(Text1) - 32),
5、0.00)End SubPrivate Sub Command2_Click() Text1 = Format(9 / 5 * Val(Text2) + 32, 0.00)End Sub或Private Sub Command1_Click() Dim f!, c! 声明两个变量 f = Val(Text1) c = 5 / 9 * (f - 32) Text2 = Format(c, 0.00) 保留两位小数End SubPrivate Sub Command2_Click() Dim ff!, cc! 声明两个变量 cc = Val(Text2) ff = 9 / 5 * cc + 32
6、Text1 = Format(ff, 0.00) 保留两位小数End SubB2Private Sub Command1_Click() Label2 = Format(Val(Text1) * Val(Text1) * 3.14, 0.00)End SubPrivate Sub Command2_Click() Label3 = Format(Val(Text1) * 3.14 * 2, 0.00)End SubPrivate Sub Text1_LostFocus() If Not IsNumeric(Text1.Text) Then MsgBox 输入有非数字字符,请重新输入, , 警告
7、 Text1.Text = Text1.SetFocus End IfEnd Sub或Private Sub Command1_Click() Label2 = Format(Val(Text1) * Val(Text1) * 3.14, 0.00)End SubPrivate Sub Command2_Click() Label3 = Format(Val(Text1) * 3.14 * 2, 0.00)End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If Not IsNumeric(T
8、ext1.Text) Then Text1.Text = End If End IfEnd SubB3Private Sub Command1_Click() n = Int(Log(2) / Log(1.008) + 1) Label1 = n & 年后人数超过26亿End SubB4Private Sub Command1_Click() Dim x, dx, cd x = Text1.Text dx = UCase(x) cd = Len(x) Print 大写字母为:; dx Print 字符串长度为:; cdEnd SubB5Private Sub Command1_Click()
9、Text1 = Int(Rnd * 900 + 100)End SubPrivate Sub Command2_Click() Dim x%, x1%, x2%, x3% x = Val(Text1) x1 = x Mod 10 分离出的个位数 x2 = (x Mod 100) 10 分离出的十位数 x3 = x 100 分离出的百位数 Label1 = x1 * 100 + x2 * 10 + x3End SubB6Private Sub Form_Click() Label1 = Left(Text1, 11) Label2 = Mid(Text1, 12, 6) Label3 = Rig
10、ht(Text1, 5)End SubB7Private Sub Command1_Click() Print For i = 1 To 5 Print Tab(15 - i * 2); String(2 * i - 1, ); Spc(18 - 4 * (i - 1); String(2 * i - 1, ) Next iEnd SubPrivate Sub Command2_Click() ClsEnd Sub进一步要求:Private Sub Command1_Click() Print For i = 1 To 5 Print Tab(15 - i * 2); String(2 * i
11、 - 1, ); String(10 - (2 * i - 1), ); String(2 * i - 1, ) Next iEnd SubPrivate Sub Command2_Click() ClsEnd SubB8Private Sub Form_Click()x = Val(InputBox(输入一正实数, 计算, 0)pf = Format(x * x, 0.000)pfg = Format(Sqr(x), 0.000)lf = Format(x * x * x, 0.000)lfg = Format(x (1 / 3), 0.000)Print 平方为:; pf; Space(5
12、); 平方根为:; pfg; Space(5); 立方为:; lf; Space(5); 立方根为:; lfgEnd Sub实验CC1Private Sub Form_Click()Dim x!, y!x = Val(InputBox(输入x的值)If x 1000 Theny = xElseIf x 2000 Theny = 0.9 * xElseIf x 3000 Theny = 0.8 * xElsey = 0.7 * xEnd IfPrint yEnd SubC2Private Sub Form_Click()Dim x!, y!x = Val(InputBox(输入上网时间)If x
13、 10 Theny = 30ElseIf x 150 Theny = 150End IfPrint yEnd SubC3Private Sub Command1_Click() Dim x!, y!, z! x = InputBox(input x) y = InputBox(input y) z = InputBox(input z) Print x y z Print 排序前; x; ; y; ; z If x y Then t = x: x = y: y = t If x z Then t = x: x = z: z = t If y z Then t = y: y = z: z = t
14、 Print 排序后 & x & & y & & zEnd SubPrivate Sub Command2_Click() Dim x!, y!, z! x = InputBox(input x) y = InputBox(input y) z = InputBox(input z) Print x y z Print 排序前; x; ; y; ; z If x y Then t = x: x = y: y = t If y z Then t = y: y = z: z = t If x a(i + 1) Thenz = a(i + 1)a(i + 1) = a(i)a(i) = zEnd I
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- VB 程序设计 教程 课后 实验 答案

链接地址:https://www.31ppt.com/p-2390040.html