《最新VisualBasic程序设计作业答案..doc》由会员分享,可在线阅读,更多相关《最新VisualBasic程序设计作业答案..doc(23页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、Four short words sum up what has lifted most successful individuals above the crowd: a little bit more.-author-dateVisualBasic程序设计作业答案.一、选择题Visual Basic程序设计作业答案作业2一、选择题1B 2C 3D 4B 5D 6A 7B 8C 9A 10D 11C 12B 13D 14C 15A 16B 17C 18B 19D 20B二、填空题 1下拉式菜单 弹出式菜单 2打开 另存为 颜色 字体 打印 3文本框 列表框 4Option Base 1 5C
2、all语句 6工程 工程属性 通用 Form1.Show 708Sub过程的过程名不能返回值,而Function过程能通过过程名返回值9窗体模块 标准模块 类模块10移出内存 无效状态11(1)2*Cosa*Sina/(2*a) (2) Sqr(s*(s-a)*(s-b)*(s-c) (3) Sin(45*3.14/180)12(1)x=1 And x=C Or a-c0 And b0 Or(a0 And b0)13False14For While Do153三、阅读下列程序,给出程序运行结果。1程序运行后,单击窗体,输出结果为:5050。23 4 3.4 35 * * *四、程序设计题1 P
3、rivate Sub Command1_Click() Dim x As Single, y As Single x = Val(Text1.Text) If x 100 Then y = x Else If x 200 Then y = 9.5 * x Else If x 300 Then y = 0.9 * x Else If x 200 If x Mod 3 0 Then Text1.Text = Text1.Text & Str(x) & Chr(13) & Chr(10) End If x = x + 1 LoopEnd Sub 3 Private Sub Form_Click()P
4、rint *;Tab(9);3,Tab(18);6;Tab(27);9;Tab(36);12PrintFor I=15 to 18Print I;For j=3 to 12 Step 3Print Tab(3*j);j*I;Next jPrint Next IEnd sub 4Private Sub Command1_Click() Unload MeEnd SubPrivate Sub Option1_Click() Text1.Text = 10 * 2End SubPrivate Sub Option2_Click() Text1.Text = 10 / 2End SubPrivate
5、Sub Option3_Click() Text1.Text = 10 + 2End SubPrivate Sub Option4_Click() Text1.Text = 10 - 2End Sub5Private Function Day(n As Integer) Select Case n Case 0 Day = 星期日 & Chr(13) & (Sunday) Case 1 Day = 星期一 & Chr(13) & (Monday) Case 2 Day = 星期二 & Chr(13) & (Tuesday) Case 3 Day = 星期三 & Chr(13) & (Wedne
6、sday) Case 4 Day = 星期四 & Chr(13) & (Thursday) Case 5 Day = 星期五 & Chr(13) & (Friday) Case 6 Day = 星期六 & Chr(13) & (Saturday) End SelectEnd FunctionPrivate Sub Text1_KeyPress(KeyAscii As Integer) Dim n As Integer n = Val(Text1.Text) If KeyAscii = 13 Then If n = 0 And n 7 Then Label1.Caption = Day(n) E
7、lse MsgBox 请输入06之间的整数! End If End If Text1.SelStart = 0 Text1.SelLength = Len(Text1.Text)End Sub6新建一个工程,在默认的窗体Form1上放置一个Picture控件,然后编写如下代码。Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 2 Then MsgBox You pressed right Button Picture1.MousePo
8、inter = vbArrow End IfEnd SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Picture1.MousePointer = vbUpArrowEnd Sub 7 Private Sub Form_Load() List1.AddItem 李敏 List1.AddItem 张华 List1.AddItem 吕晓烨 List1.AddItem 赵巍 List1.AddItem 袁莉 List1.AddItem 王津 List1.A
9、ddItem 何小渴 List1.AddItem 崔宁 List1.AddItem 陈曦 List1.AddItem 刘伟楠End SubPrivate Sub Command1_Click() If Text1.Text Then List1.AddItem Text1.Text Text1.Text = Else MsgBox 请在文本框中输入信息! End IfEnd SubPrivate Sub Command2_Click() List1.RemoveItem List1.ListIndexEnd SubPrivate Sub Command3_Click() If Command3
10、.Caption = 修改 Then Text1.Text = List1.Text Text1.SetFocus Command1.Enabled = False Command2.Enabled = False Command3.Caption = 修改确认 Else List1.List(List1.ListIndex) = Text1.Text Command1.Enabled = True Command2.Enabled = True Text1.Text = Command3.Caption = 修改 End IfEnd SubPrivate Sub List1_Click() If List1.ListIndex -1 Then Command2.Enabled = True Command3.Enabled = True End IfEnd Sub-