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

📄 网格_极值f2.frm

📁 VB 数理统计实用算法
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form frmGridArray 
   Appearance      =   0  'Flat
   BackColor       =   &H80000005&
   Caption         =   "录入数据"
   ClientHeight    =   8355
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   13125
   LinkTopic       =   "Form2"
   ScaleHeight     =   8355
   ScaleWidth      =   13125
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton cmdExit 
      Caption         =   "退  出"
      Height          =   375
      Left            =   5160
      TabIndex        =   5
      TabStop         =   0   'False
      Top             =   0
      Width           =   975
   End
   Begin VB.CommandButton cmdPrint 
      Caption         =   "打  印"
      Height          =   375
      Left            =   3960
      TabIndex        =   4
      TabStop         =   0   'False
      Top             =   0
      Width           =   975
   End
   Begin VB.CommandButton cmdCalculate 
      Caption         =   "计  算"
      Height          =   375
      Left            =   2760
      TabIndex        =   3
      TabStop         =   0   'False
      Top             =   0
      Width           =   975
   End
   Begin VB.TextBox txtInput 
      Alignment       =   2  'Center
      Height          =   270
      Left            =   1440
      TabIndex        =   2
      Top             =   120
      Width           =   1095
   End
   Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
      Height          =   7815
      Left            =   0
      TabIndex        =   0
      TabStop         =   0   'False
      Top             =   480
      Width           =   12855
      _ExtentX        =   22675
      _ExtentY        =   13785
      _Version        =   393216
      BackColorFixed  =   -2147483639
      BackColorBkg    =   16777215
   End
   Begin VB.Label Label1 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "第1行:第1列"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   120
      TabIndex        =   1
      Top             =   120
      Width           =   1095
   End
End
Attribute VB_Name = "frmGridArray"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'录入窗体
Option Explicit
Dim intI As Integer, intJ As Integer

Private Sub Form_Load()
    MSFlexGrid1.Rows = intRow + 1
    MSFlexGrid1.Cols = intCol + 1
'MSFlexGrid1.Cols-1为网格总列数
'MSFlexGrid1.Rows-1为网格总行数
'建立说明列
    For intI = 1 To MSFlexGrid1.Cols - 1
        MSFlexGrid1.Row = 0                     '说明列在第0行
        MSFlexGrid1.Col = intI                  '设定当前列
        MSFlexGrid1.Text = "第" & intI & "列"
    Next intI
'建立说明行
    For intI = 1 To MSFlexGrid1.Rows - 1
        MSFlexGrid1.Col = 0                     '说明行在第0列
        MSFlexGrid1.Row = intI                  '设定当前行
        MSFlexGrid1.Text = "第" & intI & "行"
    Next intI
    MSFlexGrid1.Row = 1
    MSFlexGrid1.Col = 1
    Label1.Caption = "第1行:第1列"
End Sub

'用户单击某个网格单元时,将该单元内容复制到文本框控件
'可以在文本框对网格数据进行编辑,然后再单击Tab键或Enter键
'使文本框中经过编辑的数据返回到原来的网格单元
Private Sub MSFlexGrid1_EnterCell()
'将当前说明列和当前说明行赋予标签
    Label1 = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 0) & ":" _
         & MSFlexGrid1.TextMatrix(0, MSFlexGrid1.Col)
'将当前单元格内容赋予文本框
    txtInput.Text = MSFlexGrid1.Text
End Sub

'按Enter键或Tab键执行一个网格数据的录入
Private Sub txtInput_KeyPress(KeyAscii As Integer)
    Dim intR As Integer, intC As Integer
    If KeyAscii = 13 Or KeyAscii = 9 Then   '13为Enter键,9为Tab键
        MSFlexGrid1.Text = txtInput.Text    '文本框数据送入网格
        intC = MSFlexGrid1.Col + 1          '焦点移到同行的下一列
        intR = MSFlexGrid1.RowSel           '单元格返回当前行
        If intC = MSFlexGrid1.Cols Then     '如果到了最后一列
            intC = MSFlexGrid1.FixedRows    'intC=1,FixedRows的缺省设置
'如果intR没有到边界行则取下一行
            If intR < MSFlexGrid1.Rows - MSFlexGrid1.FixedRows Then _
                intR = intR + 1
        End If
        MSFlexGrid1.Row = intR              '新的当前行
        MSFlexGrid1.Col = intC              '新的当前列
        MSFlexGrid1.ColSel = intC           '为单元格设置的当前列
        txtInput.Text = MSFlexGrid1.Text    '单元格数据赋予文本框
        txtInput.SetFocus                   '文本框取得焦点
    End If
End Sub

'计算
Private Sub cmdCalculate_Click()
    For intI = 1 To intRow
        For intJ = 1 To intCol
            dblArray(intI, intJ) = Val(MSFlexGrid1.TextMatrix(intI, intJ))
        Next intJ
    Next intI
    Unload Me
    frmGridResult.Visible = True
End Sub

'打印
Private Sub cmdPrint_Click()
    For intI = 1 To intRow
        Printer.Print
        MSFlexGrid1.Row = intI                  '设定当前行
        For intJ = 1 To intCol
            MSFlexGrid1.Col = intJ              '设定当前列
            Printer.Print MSFlexGrid1.Text; "; ";
        Next intJ
    Next intI
    Printer.EndDoc                              '执行打印
End Sub

'退出
Private Sub cmdExit_Click()
    Unload Me
    End
End Sub

⌨️ 快捷键说明

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