VB小程序制作_第1页
VB小程序制作_第2页
VB小程序制作_第3页
VB小程序制作_第4页
VB小程序制作_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、VB程序设计 实验目的 1)掌握VB多重窗体程序的概念。 2)掌握多重窗体程序的设计方法。 3)复习各种控件的使用方法。 采用多窗体技术编写程序,分别在不同的窗体上实现不同功能。 实验步骤 实验步骤如下: 1)建立启动窗体界面与设置对象属性。选择“新建”工程,进入窗体设计器,在 窗体中添加命令按钮组 Command1(O)Command1(5),并修改属性如图 8-1左 所示。系统默认窗体 Forml为启动窗体。 2)添加窗体。选择“工程”菜单,打幵“添加窗体”对话框。按“打幵”按钮, 添加3个标准窗体Form2Form4添加标准模块。选择“工程”菜单,打幵“添 加模块”对话框。按“打幵”按钮

2、,添加1个标准模块Modulel。 图8-1程序界面设计 3) 建立子窗体界面与设置对象属性。界面如图8-1所示,设置属性如表所示。 表8-1 Form1属性设置 对象 属性 属性值 说明 Form1 Name Form1 启动窗体 Capti on Form1 Comma nd1( 0) Capti on Who are you? Comma nd1( 1) Capti on game Comma nd1(2) Capti on writeboard Comma nd( 3) Capti on calculator Comma nd1(4) Capti on byebye Picturel

3、autoredraw false Labell capti on Lets start a won derful jour ney 表8-2Form2属性设置 对象 属性 属性值 说明 Form2 Name Form2 输入个人资料窗 口 Capti on Form2 Label11 Capti on n ame Label12 Capti on gender Label13 Capti on Is that a girl? Fream1 Capti on hobbies comma nd capti on okey Capti on Optio n1 Capti on female Valu

4、e True 默认被选中 Optio n2 Capti on male Value True 默认被选中 Check1 Capti on WoW Check2 Capti on Leagueof Legends Check3 Capti on Dungeonand Fighter Check4 Capti on QQspeed Check5 Capti on films Check6 Capti on movie 表8-3 Form3属性设置 对象 属性 属性值 说明 Form3 Name Form3 Capti on Form3 Comma nd1 Capti on happ in ess

5、Comma nd2 Capti on begi n Comma nd3 Capti on love Comma nd4 Capti on beauty Comma nd5 Capti on laugh Label1 capti on scroes Label2 Capti on 0 Timer1 in terval 500 Timer2 in terval 71 表8-4Form4属性设置 对象 属性 属性值 说明 Form4 Name Form4 Capti on Form4 Label capti on Label2 Capti on 路漫漫其修远兮 Label3 Capti on 吾将上

6、下而求索 TextBox text Picturel picture Capti on 返回 表8-5 Form5属性设置 对象 属性 属性值 说明 Form Name Form5 Capti on Form5 Comma nd1(0 9) capti on 19,0 Comma nd1(10) capti on . Comma nd2(0 4) capti on +-*/= Label2 Capti on 路漫漫其修远兮 Label3 Capti on 吾将上下而求索 TextBox text 表8-6 Form6属性设置 对象 属性 属性值 说明 Form4 Name Form6 Capt

7、i on Form6 Label capti on welcome to use thissystem aga in ! Label2 Capti on tha nk you ! Picture1 picture Timer1 12 in terval 1 Timer13 in terval 1000 4)编写代码。 编写“启动”窗体forml (Forml)中代码: Opti on Explicit Dim i As Integer, ur1 As String, N As Integer Private Sub Comma nd1_Click(l ndex As In teger) N =

8、 In dex Select Case N Case 0 Case 1 Case 2 Case 3 Case 5 End Select End Sub Private Sub Form_Activate() = True End Sub Private Sub Form_Load() = - / 2 = - / 2 Picture2 = LoadPicture(C:UsersLQRDesktopVB.) = True , 0, 0, 3000, 3000, , , , , vbSrcCopy End Sub Private Sub Timer1_Timer() On Error GoTo Er

9、r ur1 = C:UsersLQRDesktopVB. & i & .gif = LoadPicture(ur1) i = i + 1 = True , 0, 0, 3000, 3000, , , , , vbSrcCopy Exit Sub Err: i = 1 End Sub 编写“输入个人资料”窗体 form2 (Form2)中的代码: Private Sub Command1_Click() If = Then a = InputBox(You forget to input your name? , Attention!, Your name!) If a = Or a = You

10、r name! Then Exit Sub = a Else: End If End Sub Private Sub Form_Load() = - / 2 = - / 2 Picture1 = LoadPicture(C:UsersLQRDesktopVB.) = True , 0, 0, 3750, 4900, , , , , vbSrcCopy End Sub 编写“ GAME窗体form3 (Form3)中的代码: Dim a As Integer, i As Integer, ur1 As String Private Sub Command1_Click() If = RGB(22

11、5, 0, 0) Then Label2 = Val + 1 End If End Sub Private Sub Command2_Click() = True End Sub Private Sub Command3_Click() If = RGB(225, 0, 0) Then Label2 = Val + 1 End If End Sub Private Sub Command4_Click() If = RGB(225, 0, 0) Then Label2 = Val + 1 End If End Sub Private Sub Command5_Click() If = RGB(

12、225, 0, 0) Then Label2 = Val + 1 End If End Sub Private Sub cw_Click() Label2 = End Sub Private Sub Timer2_Timer() On Error GoTo Err 新建文件夹 . & i & .jpg = LoadPicture(ur1) i = i + 1 = True , 0, 0, 12135, 8295, , , , , vbSrcCopy Exit Sub Err: i = 45 End Sub Private Sub Form_Load() = - / 2 = - / 2 新建文件

13、夹 .) = True , 0, 0, 12135, 8295, , , , , vbSrcCopy End Sub Private Sub Timer1_Timer() Static x As Integer a = Int(Rnd() * 4) Select Case a Case 0 = RGB(225, 0, 0) = RGB(15, 0, 0) = RGB(15, 0, 0) Case 1 = RGB(225, 0, 0) = RGB(15, 0, 0) = RGB(15, 0, 0) = RGB(15, 0, 0) Case 2 = RGB(225, 0, 0) = RGB(15,

14、 0, 0) = RGB(15, 0, 0) = RGB(15, 0, 0) Case 3 = RGB(225, 0, 0) = RGB(15, 0, 0) = RGB(15, 0, 0) = RGB(15, 0, 0) End Select If x 50 Then x = x + 1 Else = False = RGB(15, 0, 0) = RGB(15, 0, 0) = RGB(15, 0, 0) x = 0 End If End Sub Private Sub tui_Click() End Sub Private Sub wf_Click() more MsgBoxrules :

15、 & Chr(13) & Hit the different the fixed time, hits, more scores! , vbOKOnly, Rule End Sub 编写“ writeboard ”窗体 form4 (Form4)中的代码: Private Sub N_Click() _ Illi End Sub Private Sub O_Click() = 所有文件( *.* ) |*.*| 文本文件( *.TXT ) |*.txt = 1 End Sub Private Sub S_Click() End Sub Private Sub T_Click() End Sub

16、 Private Sub Text1_Change() End Sub Private Sub Y_Click() End Sub Private Sub Z_Click() = 3 Or 256 With Text1 .FontName = .FontSize = .FontStrikethru = .FontBold = .FontItalic = .FontUnderline = .ForeColor = End With End Sub Private Sub Form_Load() = - / 2 = - / 2 Picture1 = LoadPicture(C:UsersLQRDe

17、sktopVB.) = True , 0, 0, 1500, 2500, , , , , vbSrcCopy End Sub 编写“ calculator ”窗体 form5 (Form5)中的代码: Dim v As Boolean Dim S As Integer Dim x As Double Dim Y As Double Private Sub Command1_Click(Index As Integer) If = T Then If Index = 10 Then = 0 Else = Command1(Index).Caption End If Else = & Comman

18、d1(Index).Caption End If End Sub Private Sub Command2_Click(Index As Integer) = T If v Then x = Val v = Not v Else Y = Val Select Case S Case 0 = x + Y Case 1 = x - Y Case 2 = x * Y Case 3 If Y 0 Then = x / Y Else MsgBox 傻了?不能以 0为除数啊! , vbOKOnly, 提示 v = False End If Case 4 Y = 0 v = False End Select

19、 x = Val End If S = Index End Sub Private Sub Form_Load() = - / 2 = - / 2 End Sub Private Sub tui_Click() End Sub Private Sub xin_Click() Illi End Sub 编写结束窗体form6 (Form6)中的代码: Option Explicit Dim x As Integer, Y As Integer, a As Integer, m As Long, N As Long Private Sub Form_Activate() = True = True

20、 = True = True = True = True End Sub Private Sub Form_Load() = - / 2 = - / 2 Picture1 = LoadPicture(C:UsersLQRDesktopVB.) = True , 0, 0, 2250, 2250, , , , , vbSrcCopy Picture2 = LoadPicture(C:UsersLQRDesktopVB.) = True , 0, 0, 2250, 2250, , , , , vbSrcCopy Picture3 = LoadPicture(C:UsersLQRDesktopVB.) = True , 0, 0, 2250, 2250, , , , , vbSrcCopy End Sub Private Sub Timer

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论