文档详情

第8章Visual Basic程序设计.doc

发布:2017-01-15约2.5万字共69页下载文档
文本预览下载声明
第8章Visual Basic程序设计 教学要求 要求掌握: ??1.ListBox的常用属性及ListIndex属性的应用。 ??2.Form_Load事件的应用。 ??3.在ListBox中添加项目及用LoadPicture装载图像的方法。 ??4.选择结构程序的设计方法及条件语句的应用。 要求了解: ???赋值语句、运算符、条件语句 重点: ??用ListBox等控件设计用户界面,?Form_Load事件的应用,在ListBox中添加项目,ListBox的ListIndex属性的应用,选择结构程序设计的方法及条件语句的应用。 难点: ???选择结构程序设计的方法及程序代码的编写。 1.?规划:? 2.?设计?Form1 对? 象 属? 性 属性值 Form1 Border 选0-None?? Label1 Caption 电子通讯录 Line1 Border Color 调色板,选¢? Border Style 选1-Solid? Border Width 选2 ? Label2 Caption 姓名 Label3 Caption 电话号码 Label4 Caption E-mail地址 Label5 Caption 照片 Alignment 选1-Left Justify List1 List 为空 Text1 Text 为空 Text2 Text 为空 Imagel1 Border Style 选1-Fixed Command1 Caption 退出 3.?完善? ???双击Form1窗体,打开代码窗口→在“对象”下CheckBox表中选择Form,在“过程”?下拉列表中选择Load,输入代码,添加姓名: Private?Sub?Form_Load ??List1.AddItem?”埃及” ?List.?AddItem?“埃及”,表示在列表框添加项目, ??List1.AddItem?”美国” ??List1.AddItem?”荷兰” ??List1.AddItem?”意大利” ??List1.AddItem?”法国” ??List1.AddItem?”英国” End?Sub →在“对象”下拉列表中选择List1,在“过程”?下拉列表中选择Click,输入代码: Private?Sub?List1_Click ??Click:单击鼠标左键 ??If?List1.ListIndex?=?0?Then???ListIndex属性,选中的项目在列表中排位, Text1.Text?=?”0566-2029708”??排序号从0开始 Text2.Text?=?”Sphinx@” Image1.Stretch?=?True ??Stretch属性,调整图形大小以适应图像框 ?? sp;?Image1.Picture?=?LoadPicture ??End?If ???Picture属性,图像框中设置显示的图形 ??If?List1.ListIndex?=?1?Then???LoadPicture函数的作用是装载图片 Text1.Text?=?”001 Text2.Text?=?”Hawaii@” Image1.Stretch?=?True Image1.Picture?=?LoadPicture ??End?If ??LoadPicture装载的图片在当前文件夹,使用相对路径 If?List1.ListIndex?=?2?Then ??Text1.Text?=?”0566-2029708” ??Text2.Text?=?”Windmill@” ??Image1.Stretch?=?True ??Image1.Picture?=?LoadPicture End?If If?List1.ListIndex?=?3?Then ??Text1.Text?=?”0566-2029708” ??Text2.Text?=?”V
显示全部
相似文档