夏VB程序设计教程第版课后实验答案

上传人:公**** 文档编号:508539591 上传时间:2023-04-26 格式:DOC 页数:118 大小:217.51KB
返回 下载 相关 举报
夏VB程序设计教程第版课后实验答案_第1页
第1页 / 共118页
夏VB程序设计教程第版课后实验答案_第2页
第2页 / 共118页
夏VB程序设计教程第版课后实验答案_第3页
第3页 / 共118页
夏VB程序设计教程第版课后实验答案_第4页
第4页 / 共118页
夏VB程序设计教程第版课后实验答案_第5页
第5页 / 共118页
点击查看更多>>
资源描述

《夏VB程序设计教程第版课后实验答案》由会员分享,可在线阅读,更多相关《夏VB程序设计教程第版课后实验答案(118页珍藏版)》请在金锄头文库上搜索。

1、A1Private 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() Label1.M

2、ove 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_Db

3、lClick() 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 + 200

4、 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 SubB1Private Sub Command1_Click() Text2 = Format(5 / 9 * (Val(Text1) - 32), 0.00)E

5、nd 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 Text1

6、= 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 输入有非数字字符,请重新输入, , 警告 Text1

7、.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(Text1.T

8、ext) 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() Text1

9、= 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 = Right(Tex

10、t1, 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 - 1,

11、); 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 SubC1Private 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 10 Theny

13、 = 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 Print 排序后 & x & & y & & zEnd SubPrivate Sub Command2_Click() Dim x!, y!, z! x = InputBox(input x) y = InputBox(input y) z

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 医学/心理学 > 基础医学

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号