📄 frmarr04.frm
字号:
VERSION 5.00
Begin VB.Form frmArr04
Caption = "Fig. 7.4: Student Poll Analysis"
ClientHeight = 3165
ClientLeft = 2745
ClientTop = 1725
ClientWidth = 4530
BeginProperty Font
Name = "Courier"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
LinkTopic = "Form1"
PaletteMode = 1 'UseZOrder
ScaleHeight = 3165
ScaleWidth = 4530
Begin VB.CommandButton cmdExit
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "Exit"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 2880
TabIndex = 1
Top = 1320
Width = 1335
End
Begin VB.CommandButton cmdPrint
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "Print"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 2880
TabIndex = 0
Top = 240
Width = 1335
End
End
Attribute VB_Name = "frmArr04"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 7.4
' Student poll analysis program
Option Explicit
' Set default lower bound to 1
Option Base 1
Dim mResponses(40) As Integer
Private Sub Form_Load()
Dim x As Integer
' Generate survey data
For x = LBound(mResponses) To UBound(mResponses)
mResponses(x) = 1 + Int(Rnd() * 10)
Next x
End Sub
Private Sub cmdPrint_Click()
Dim frequency(10) As Integer ' 10 Elements
Dim x As Integer
Call Cls
Call Randomize
' Calculate results
For x = LBound(mResponses) To UBound(mResponses)
frequency(mResponses(x)) = frequency(mResponses(x)) + 1
Next x
Print "Rating" & Space$(3) & "Frequency"
For x = LBound(frequency) To UBound(frequency)
Print Space$(3) & x & vbTab & vbTab & frequency(x)
Next x
cmdPrint.Enabled = False
End Sub
Private Sub cmdExit_Click()
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -