VisualBasic程序设计作业答案.pdf
Visual BasicVisual Basic 程序设计作业答案程序设计作业答案作业作业 2 2一、选择题一、选择题1 B2 C3 D4 B5 D6 A7 B8 C9 A10 D11 C12B13D14C15A16B17C18B19D20B二、填空题二、填空题1下拉式菜单弹出式菜单2翻开另存为颜色字体打印3文本框列表框4Option Base 15Call 语句6工程工程属性通用708Sub 过程的过程名不能返回值,而Function 过程能通过过程名返回值9窗体模块标准模块类模块10移出内存无效状态11 12*Cos*Sin/(2*)(2)Sqr(s*(s-a)*(s-b)*(s-c)(3)Sin(45*3.14/180)12 1x=1 And x=C Or a-c0 And b0 Or(a0 And b0)13False14ForWhileDo153三、阅读以下程序,给出程序运行结果。三、阅读以下程序,给出程序运行结果。1程序运行后,单击窗体,输出结果为:5050。2343.435*四、程序设计题四、程序设计题1Private Sub Command1_Click()Dim x As Single,y As Singlex=Val(Text1.Text)If x 100 Theny=xElseIf x 200 Theny=9.5*xElseIf x 300 Theny=0.9*xElseIf x 200If x Mod 3 0 ThenText1.Text=Text1.Text&Str(x)&Chr(13)&Chr(10)End Ifx=x+1LoopEnd Sub3Private Sub Form_Click()Print*;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 jPrintNext IEnd sub4Private Sub Command1_Click()Unload MeEnd SubPrivate Sub Option1_Click()Text1.Text=10*2End SubPrivate Sub Option2_Click()Text1.Text=10/2End SubPrivate Sub Option3_Click()Text1.Text=10+2End SubPrivate Sub Option4_Click()Text1.Text=10-2End Sub5Private Function Day(n As Integer)Select Case nCase 0Day=星期日&Chr(13)&(Sunday)Case 1Day=星期一&Chr(13)&(Monday)Case 2Day=星期二&Chr(13)&(Tuesday)Case 3Day=星期三&Chr(13)&(Wednesday)Case 4Day=星期四&Chr(13)&(Thursday)Case 5Day=星期五&Chr(13)&(Friday)Case 6Day=星期六&Chr(13)&(Saturday)End SelectEnd FunctionPrivate Sub Text1_KeyPress(KeyAscii As Integer)Dim n As Integern=Val(Text1.Text)If KeyAscii=13 ThenIf n=0 And n 7 ThenLabel1.Caption=Day(n)ElseMsgBox 请输入 06 之间的整数!End IfEnd IfText1.SelStart=0Text1.SelLength=Len(Text1.Text)End Sub6新建一个工程,在默认的窗体Form1 上放置一个 Picture 控件,然后编写如下代码。Private Sub Picture1_MouseDown(Button As Integer,Shift As Integer,X As Single,Y AsSingle)If Button=2 ThenMsgBox You pressed right ButtonPicture1.MousePointer=vbArrowEnd IfEnd SubPrivate Sub Picture1_MouseMove(Button As Integer,Shift As Integer,X As Single,Y AsSingle)Picture1.MousePointer=vbUpArrowEnd Sub7Private Sub Form_Load()List1.AddItem 李敏List1.AddItem 张华List1.AddItem 吕晓烨List1.AddItem 赵巍List1.AddItem 袁莉List1.AddItem 王津List1.AddItem 何小渴List1.AddItem 崔宁List1.AddItem 陈曦List1.AddItem 刘伟楠End SubPrivate Sub Command1_Click()If Text1.Text ThenText1.Text=ElseMsgBox 请在文本框中输入信息!End IfEnd SubPrivate Sub Command2_Click()End SubPrivate Sub Command3_Click()If Command3.Caption=修改 ThenCommand1.Enabled=FalseCommand2.Enabled=FalseCommand3.Caption=修改确认ElseCommand1.Enabled=TrueCommand2.Enabled=TrueText1.Text=Command3.Caption=修改End IfEnd SubPrivate Sub List1_Click()If List1.ListIndex -1 ThenCommand2.Enabled=TrueCommand3.Enabled=TrueEnd IfEnd Sub