⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmpao.frm

📁 是《VISUAL BASIC编程》(英文原版 提高版) 的8个习题 已完成 供大家参考
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmPao 
   Caption         =   "Form1"
   ClientHeight    =   5310
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7260
   LinkTopic       =   "Form1"
   ScaleHeight     =   5310
   ScaleWidth      =   7260
   StartUpPosition =   3  '窗口缺省
   Begin VB.ListBox lstAge 
      Height          =   1140
      ItemData        =   "frmPao.frx":0000
      Left            =   2160
      List            =   "frmPao.frx":0002
      TabIndex        =   25
      Top             =   840
      Width           =   1695
   End
   Begin VB.ListBox lstParty 
      Height          =   1140
      Left            =   240
      TabIndex        =   24
      Top             =   840
      Width           =   1575
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "&Exit"
      Height          =   735
      Left            =   5280
      TabIndex        =   23
      Top             =   3120
      Width           =   1575
   End
   Begin VB.CommandButton cmdPrint 
      Caption         =   "&Print"
      Height          =   735
      Left            =   5280
      TabIndex        =   22
      Top             =   2160
      Width           =   1575
   End
   Begin VB.CommandButton cmdDisplay 
      Caption         =   "&Display"
      Height          =   735
      Left            =   5280
      TabIndex        =   21
      Top             =   1200
      Width           =   1575
   End
   Begin VB.CommandButton cmdEnter 
      Caption         =   "&Enter"
      Height          =   615
      Left            =   5280
      TabIndex        =   20
      Top             =   360
      Width           =   1575
   End
   Begin VB.Frame Frame1 
      Height          =   2535
      Left            =   120
      TabIndex        =   0
      Top             =   2280
      Width           =   4455
      Begin VB.Label lblInd 
         Appearance      =   0  'Flat
         BackColor       =   &H8000000B&
         BorderStyle     =   1  'Fixed Single
         ForeColor       =   &H80000008&
         Height          =   375
         Index           =   3
         Left            =   3480
         TabIndex        =   19
         Top             =   1800
         Width           =   495
      End
      Begin VB.Label lblInd 
         Appearance      =   0  'Flat
         BackColor       =   &H8000000B&
         BorderStyle     =   1  'Fixed Single
         ForeColor       =   &H80000008&
         Height          =   375
         Index           =   2
         Left            =   2640
         TabIndex        =   18
         Top             =   1800
         Width           =   495
      End
      Begin VB.Label lblInd 
         Appearance      =   0  'Flat
         BackColor       =   &H8000000B&
         BorderStyle     =   1  'Fixed Single
         ForeColor       =   &H80000008&
         Height          =   375
         Index           =   1
         Left            =   1800
         TabIndex        =   17
         Top             =   1800
         Width           =   495
      End
      Begin VB.Label lblInd 
         Appearance      =   0  'Flat
         BackColor       =   &H8000000B&
         BorderStyle     =   1  'Fixed Single
         ForeColor       =   &H80000008&
         Height          =   375
         Index           =   0
         Left            =   960
         TabIndex        =   16
         Top             =   1800
         Width           =   495
      End
      Begin VB.Label lblRep 
         Appearance      =   0  'Flat
         BackColor       =   &H8000000B&
         BorderStyle     =   1  'Fixed Single
         ForeColor       =   &H80000008&
         Height          =   375
         Index           =   3
         Left            =   3480
         TabIndex        =   15
         Top             =   1200
         Width           =   495
      End
      Begin VB.Label lblRep 
         Appearance      =   0  'Flat
         BackColor       =   &H8000000B&
         BorderStyle     =   1  'Fixed Single
         ForeColor       =   &H80000008&
         Height          =   375
         Index           =   2
         Left            =   2640
         TabIndex        =   14
         Top             =   1200
         Width           =   495
      End
      Begin VB.Label lblRep 
         Appearance      =   0  'Flat
         BackColor       =   &H8000000B&
         BorderStyle     =   1  'Fixed Single
         ForeColor       =   &H80000008&
         Height          =   375
         Index           =   1
         Left            =   1800
         TabIndex        =   13
         Top             =   1200
         Width           =   495
      End
      Begin VB.Label lblRep 
         Appearance      =   0  'Flat
         BackColor       =   &H8000000B&
         BorderStyle     =   1  'Fixed Single
         ForeColor       =   &H80000008&
         Height          =   375
         Index           =   0
         Left            =   960
         TabIndex        =   12
         Top             =   1200
         Width           =   495
      End
      Begin VB.Label lblDem 
         Appearance      =   0  'Flat
         BackColor       =   &H8000000B&
         BorderStyle     =   1  'Fixed Single
         ForeColor       =   &H80000008&
         Height          =   375
         Index           =   3
         Left            =   3480
         TabIndex        =   11
         Top             =   600
         Width           =   495
      End
      Begin VB.Label lblDem 
         Appearance      =   0  'Flat
         BackColor       =   &H8000000B&
         BorderStyle     =   1  'Fixed Single
         ForeColor       =   &H80000008&
         Height          =   375
         Index           =   2
         Left            =   2640
         TabIndex        =   10
         Top             =   600
         Width           =   495
      End
      Begin VB.Label lblDem 
         Appearance      =   0  'Flat
         BackColor       =   &H8000000B&
         BorderStyle     =   1  'Fixed Single
         ForeColor       =   &H80000008&
         Height          =   375
         Index           =   1
         Left            =   1800
         TabIndex        =   9
         Top             =   600
         Width           =   495
      End
      Begin VB.Label lblDem 
         Appearance      =   0  'Flat
         BackColor       =   &H8000000B&
         BorderStyle     =   1  'Fixed Single
         ForeColor       =   &H80000008&
         Height          =   375
         Index           =   0
         Left            =   960
         TabIndex        =   8
         Top             =   600
         Width           =   495
      End
      Begin VB.Label Label7 
         Caption         =   "over65"
         Height          =   255
         Left            =   3480
         TabIndex        =   7
         Top             =   240
         Width           =   735
      End
      Begin VB.Label Label6 
         Caption         =   "51-65"
         Height          =   255
         Left            =   2640
         TabIndex        =   6
         Top             =   240
         Width           =   735
      End
      Begin VB.Label Label5 
         Caption         =   "36-50"
         Height          =   255
         Left            =   1800
         TabIndex        =   5
         Top             =   240
         Width           =   615
      End
      Begin VB.Label Label4 
         Caption         =   "18-35"
         Height          =   255
         Left            =   960
         TabIndex        =   4
         Top             =   240
         Width           =   495
      End
      Begin VB.Label Label3 
         Caption         =   "Ind"
         Height          =   375
         Left            =   120
         TabIndex        =   3
         Top             =   1800
         Width           =   495
      End
      Begin VB.Label Label2 
         Caption         =   "Rep"
         Height          =   375
         Left            =   120
         TabIndex        =   2
         Top             =   1200
         Width           =   495
      End
      Begin VB.Label Label1 
         Caption         =   "Dem"
         Height          =   375
         Left            =   120
         TabIndex        =   1
         Top             =   600
         Width           =   495
      End
   End
   Begin VB.Label Label11 
      AutoSize        =   -1  'True
      Caption         =   "&Political Party"
      Height          =   180
      Left            =   240
      TabIndex        =   27
      Top             =   480
      Width           =   1350
   End
   Begin VB.Label lblAge 
      AutoSize        =   -1  'True
      Caption         =   "&Age:"
      Height          =   180
      Left            =   2160
      TabIndex        =   26
      Top             =   480
      Width           =   360
   End
End
Attribute VB_Name = "frmPao"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdDisplay_Click()
    Dim strParty As String, intAge As String, intCount As Integer
    
    For intCount = 0 To 3
        lblDem(intCount).Caption = ""
        lblRep(intCount).Caption = ""
        lblInd(intCount).Caption = ""
    Next intCount
    Open "D:\pao.txt" For Input As #1
    Do While Not EOF(1)
        Input #1, strParty, intAge
        Select Case strParty
            Case "Democrat"
                lblDem(intAge).Caption = Val(lblDem(intAge).Caption) + 1
            Case "Republican"
                lblRep(intAge).Caption = Val(lblRep(intAge).Caption) + 1
            Case "Independent"
                lblInd(intAge).Caption = Val(lblInd(intAge).Caption) + 1
        End Select
    Loop
    Close #1
End Sub

Private Sub cmdEnter_Click()
    Open "D:\pao.txt" For Append As #1
    Write #1, lstParty.Text, lstAge.ListIndex
    Close #1
End Sub

Private Sub cmdExit_Click()
    Unload frmPao
End Sub

Private Sub cmdPrint_Click()
 
    Dim intX As Integer, intDem As Integer, intRep As Integer
    Dim intInd As Integer, intTotal As Integer
    Dim strFont As String, sngSize As Single
    Dim strPS1 As String * 3, strPS2 As String * 3, strPS3 As String * 3
    Dim strPS4 As String * 3, strPS5 As String * 4
    
    For intX = 0 To 3
        intDem = intDem + Val(lblDem(intX).Caption)
        intRep = intRep + Val(lblRep(intX).Caption)
        intInd = intInd + Val(lblInd(intX).Caption)
    Next intX
    intTotal = intDem + intRep + intInd
    
    strFont = Printer.Font
    sngSize = Printer.FontSize
    Printer.Font = "courier new"
    Printer.FontSize = 10
    Printer.Print Tab(30); "PAO Information - 1999"
    Printer.Print
    Printer.Print Tab(5); "Party"; Tab(20); "18-35"; Tab(30); "36-50"; _
                  Tab(40); "51-65"; Tab(50); "Over 65"; Tab(60); "Total"
    
    RSet strPS1 = Format(lblDem(0).Caption, "general number")
    RSet strPS2 = Format(lblDem(1).Caption, "general number")
    RSet strPS3 = Format(lblDem(2).Caption, "general number")
    RSet strPS4 = Format(lblDem(3).Caption, "general number")
    RSet strPS5 = Format(intDem, "general number")
    Printer.Print Tab(5); "Democrat"; Tab(22); strPS1; Tab(32); strPS2; _
                    Tab(42); strPS3; Tab(54); strPS4; Tab(61); strPS5
    
    RSet strPS1 = Format(lblRep(0).Caption, "general number")
    RSet strPS2 = Format(lblRep(1).Caption, "general number")
    RSet strPS3 = Format(lblRep(2).Caption, "general number")
    RSet strPS4 = Format(lblRep(3).Caption, "general number")
    RSet strPS5 = Format(intRep, "general number")
    Printer.Print Tab(5); "Republican"; Tab(22); strPS1; Tab(32); strPS2; _
                    Tab(42); strPS3; Tab(54); strPS4; Tab(61); strPS5
    
    RSet strPS1 = Format(lblInd(0).Caption, "general number")
    RSet strPS2 = Format(lblInd(1).Caption, "general number")
    RSet strPS3 = Format(lblInd(2).Caption, "general number")
    RSet strPS4 = Format(lblInd(3).Caption, "general number")
    RSet strPS5 = Format(intInd, "general number")
    Printer.Print Tab(5); "Independent"; Tab(22); strPS1; Tab(32); strPS2; _
                    Tab(42); strPS3; Tab(54); strPS4; Tab(61); strPS5
    Printer.Print
    Printer.Print
    
    RSet strPS5 = Format(intTotal, "general number")
    Printer.Print Tab(41); "Total respondents"; Tab(61); strPS5
    Printer.Print
    Printer.Print Tab(5); "End of report"
    Printer.EndDoc
    Printer.Font = strFont
    Printer.FontSize = sngSize
End Sub

Private Sub Form_Load()
    frmPao.Top = (Screen.Height - frmPao.Height) / 2
    frmPao.Left = (Screen.Width - frmPao.Width) / 2
    lstAge.AddItem "18 - 35"
    lstAge.AddItem "36 - 50"
    lstAge.AddItem "51 - 65"
    lstAge.AddItem "Over 65"
    lstParty.AddItem "Republican"
    lstParty.AddItem "Independent"
    lstParty.AddItem "Democrat"
    lstParty.ListIndex = 0
    lstAge.ListIndex = 1
End Sub

Private Sub lblReq_Click(Index As Integer)

End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -