<VB数理统计实用算法>书中的算法源程序
源代码在线查看: 数据文件_编辑f1.frm
VERSION 5.00
Begin VB.Form frmDisplayRowCol
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "显示文件的列数和行数、总行数"
ClientHeight = 2025
ClientLeft = 60
ClientTop = 345
ClientWidth = 6420
LinkTopic = "Form1"
ScaleHeight = 2025
ScaleWidth = 6420
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdExit
Caption = "退 出"
Height = 375
Left = 4920
TabIndex = 9
ToolTipText = "结束程序运行"
Top = 1440
Width = 1215
End
Begin VB.CommandButton cmdOK
Caption = "确 定"
Height = 375
Left = 3600
TabIndex = 8
ToolTipText = "单击后,按列数或行数或用文本框或用网格"
Top = 1440
Width = 1215
End
Begin VB.Label lblRowAllCount
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
ForeColor = &H80000008&
Height = 375
Left = 4800
TabIndex = 7
Top = 720
Width = 975
End
Begin VB.Label lblRowCount
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
ForeColor = &H80000008&
Height = 375
Left = 2520
TabIndex = 6
Top = 720
Width = 975
End
Begin VB.Label lblColCount
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
ForeColor = &H80000008&
Height = 375
Left = 600
TabIndex = 5
Top = 720
Width = 975
End
Begin VB.Label Label5
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "(包括图题、列标和行标)"
ForeColor = &H80000008&
Height = 375
Left = 4080
TabIndex = 4
Top = 360
Width = 2415
End
Begin VB.Label Label4
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "(不计图题、列标和行标)"
ForeColor = &H80000008&
Height = 375
Left = 1920
TabIndex = 3
Top = 360
Width = 2295
End
Begin VB.Label Label3
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "文件的总行数"
ForeColor = &H80000008&
Height = 255
Left = 4440
TabIndex = 2
Top = 120
Width = 1695
End
Begin VB.Label Label2
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "文件的行数"
ForeColor = &H80000008&
Height = 255
Left = 2160
TabIndex = 1
Top = 120
Width = 1695
End
Begin VB.Label Label1
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "文件的列数"
ForeColor = &H80000008&
Height = 255
Left = 240
TabIndex = 0
Top = 120
Width = 1695
End
End
Attribute VB_Name = "frmDisplayRowCol"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'显示文件的列数、行数和总行数
Option Explicit
Private Sub Form_Load()
Dim vntA As Variant, intI As Integer, intJ As Integer
intFileNumber = FreeFile '取得文件号码
Open strFileName For Input As intFileNumber '打开文件
Input #intFileNumber, vntA '读列数
intCol = vntA
lblColCount = intCol '在标签中显示列数
For intJ = 2 To intCol '读*******
Input #intFileNumber, vntA
Next intJ
Input #intFileNumber, vntA '读行数
intRow = vntA
lblRowCount = intRow '在标签中显示行数
For intJ = 2 To intCol '读*******
Input #intFileNumber, vntA
Next intJ
Input #intFileNumber, vntA '读总行数
intRowAll = vntA
lblRowAllCount = intRowAll '在标签中显示总行数
For intJ = 2 To intCol '读*******
Input #intFileNumber, vntA
Next intJ
Close
End Sub
'确定
Private Sub cmdOK_Click()
Unload Me '卸载当前窗体
blnTitle = False: blnRowLabel = False: blnColLabel = False
'优先考虑图题
If intRowAll > intRow + 3 Then blnTitle = True
'其次考虑行标
If intRowAll > 2 * intRow Then blnRowLabel = True
'最后考虑列标
If intRowAll = 2 * intRow + 5 Then blnColLabel = True
'按行数和列数重新定义数组
ReDim vntArray(1 To intRowAll, 1 To intCol)
If intRowAll > 30 Or intCol > 14 Then
'30和14这两个参数与显示屏有关,需要按实际情况修改
frmGrid.Visible = True '显示网格编辑数据窗体
Else
frmText.Visible = True '显示文本框编辑数据窗体
End If
End Sub
'退出
Private Sub cmdExit_Click()
Unload Me
End
End Sub