📄 新建 文本文档.txt
字号:
Option Explicit
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:\zuoye\exe6\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:\zuoye\exe6\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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -