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

📄 曲线_插值f2.frm

📁 <VB数理统计实用算法>书中的算法源程序
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmCalculate 
   Appearance      =   0  'Flat
   BackColor       =   &H80000005&
   Caption         =   "曲线_插值"
   ClientHeight    =   2175
   ClientLeft      =   165
   ClientTop       =   555
   ClientWidth     =   5160
   LinkTopic       =   "Form1"
   ScaleHeight     =   3.836
   ScaleMode       =   7  'Centimeter
   ScaleWidth      =   9.102
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox Text1 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      Height          =   270
      Left            =   3120
      TabIndex        =   9
      Top             =   600
      Width           =   1815
   End
   Begin VB.ListBox List1 
      Appearance      =   0  'Flat
      Height          =   1110
      ItemData        =   "曲线_插值F2.frx":0000
      Left            =   1200
      List            =   "曲线_插值F2.frx":0016
      TabIndex        =   7
      Top             =   480
      Width           =   1695
   End
   Begin VB.TextBox txtData 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      Height          =   270
      Index           =   0
      Left            =   120
      TabIndex        =   4
      Text            =   "txtData"
      Top             =   120
      Visible         =   0   'False
      Width           =   975
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "退  出"
      Height          =   375
      Left            =   2040
      TabIndex        =   2
      Top             =   1680
      Width           =   975
   End
   Begin VB.CommandButton cmdSaveR 
      Caption         =   "保  存"
      Height          =   375
      Left            =   3000
      TabIndex        =   1
      Top             =   1680
      Width           =   975
   End
   Begin VB.CommandButton cmdCalculate 
      Caption         =   "计  算"
      Height          =   375
      Left            =   1080
      TabIndex        =   0
      Top             =   1680
      Width           =   975
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "插值结果"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   3480
      TabIndex        =   8
      Top             =   360
      Width           =   1215
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "插值方法"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   1440
      TabIndex        =   6
      Top             =   240
      Width           =   1215
   End
   Begin VB.Label lblRow 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      BorderStyle     =   1  'Fixed Single
      Caption         =   "lblRow"
      ForeColor       =   &H80000008&
      Height          =   255
      Index           =   0
      Left            =   120
      TabIndex        =   5
      Top             =   360
      Visible         =   0   'False
      Width           =   975
   End
   Begin VB.Label lblCol 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      BorderStyle     =   1  'Fixed Single
      Caption         =   "lblCol"
      ForeColor       =   &H80000008&
      Height          =   255
      Index           =   0
      Left            =   120
      TabIndex        =   3
      Top             =   600
      Visible         =   0   'False
      Width           =   975
   End
End
Attribute VB_Name = "frmCalculate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'曲线_插值计算窗体
Dim intI As Integer, intJ As Integer

Private Sub Form_Load()
    cmdSaveR.Visible = False                    '“保存”命令按钮不可视
    Dim vntA As Variant
    intFileNumber = FreeFile                    '取得文件号码
    Open strFileName For Input As intFileNumber '打开文件
'形成文本框数组
    For intI = 1 To intRowAll
        For intJ = 1 To intCol
            Input #intFileNumber, vntA
            Load txtData((intI - 1) * intCol + intJ)
            txtData((intI - 1) * intCol + intJ).Text = vntA
        Next intJ
    Next intI
'形成上部标签
    For intI = 1 To intCol
        Input #intFileNumber, vntA
        Load lblCol(intI)
        lblCol(intI).Caption = vntA
    Next intI
'形成左边标签
    For intI = 1 To intRowAll
        Input #intFileNumber, vntA
        Load lblRow(intI)
        lblRow(intI).Caption = vntA
    Next intI
    Close
    List1.ListIndex = 3                         '缺省方法为牛顿插值法
'使显示插值结果的文本框不可视
    Label2.Visible = False
    Text1.Visible = False
End Sub

'计算
Private Sub cmdCalculate_Click()
    Dim F As Double, FF As Single
    If frmFileName.Option2 Then
'单点插值
        OneP X, Y, A, F, List1.ListIndex
'使显示插值结果的文本框可视
        Label2.Visible = True
        Text1.Visible = True
        FF = F                      '将双精度变换成单精度
        Text1.Text = Str(FF)
    Else
'多点等距插值
        ReDim R(1 To 2, 1 To M)
'List1.ListIndex给定方法
        Equal X, Y, R, List1.ListIndex
        cmdSaveR.Visible = True     '“保存”命令按钮可视
    End If
End Sub

'保存文件过程
Private Sub FileSave(strName As String)
    Dim intNumber As Integer
    Dim vntA As Variant
    MsgBox "现在存盘,请耐心等待!"
    intNumber = FreeFile                            '取得空闲的文件号
    Open strName For Output As intNumber            '打开文件
'保存数据
    For intI = 1 To intRowAll
        For intJ = 1 To intCol
            Write #intNumber, txtData((intI - 1) * intCol + intJ);
        Next intJ
    Next intI
'保存上部标签
    For intI = 1 To intCol
        Write #intNumber, lblCol(intI).Caption;
    Next intI
'保存左边标签
    For intI = 1 To intRowAll
        Write #intNumber, lblRow(intI).Caption;
    Next intI
    Close                                           '关闭文件
    MsgBox "存盘完成,请继续进行!"
End Sub

'将计算结果保存为数据文件
Private Sub cmdSaveR_Click()
    Dim sngR As Single, intN As Integer
'重新建立网格体系,需要先卸载原有的网格体系
    For intI = 1 To intRowAll
        For intJ = 1 To intCol
            Unload txtData((intI - 1) * intCol + intJ)
        Next intJ
    Next intI
    For intI = 1 To intCol
        Unload lblCol(intI)
    Next intI
    For intI = 1 To intRowAll
        Unload lblRow(intI)
    Next intI
'保存网格化数据
'网格化时的列数、行数和总行数都有改变,需要重新建立网格体系
'行数由2行变成1行,总行数需要减2(包括一个数据行和一个行标)
    intRow = 1: intRowAll = intRowAll - 2: intCol = M
    For intI = 1 To intRowAll
        For intJ = 1 To intCol
            Load txtData((intI - 1) * intCol + intJ)
        Next intJ
    Next intI
    For intI = 1 To intCol
        Load lblCol(intI)
    Next intI
    For intI = 1 To intRowAll
        Load lblRow(intI)
    Next intI
    lblRow(1).Caption = "列数"
    txtData(1).Text = intCol                            '列数
    For intI = 2 To intCol
        txtData(intI) = "*******"
    Next intI
    lblRow(2).Caption = "行数"
    txtData(intCol + 1).Text = intRow                   '行数
    For intI = 2 To intCol
        txtData(intCol + intI) = "*******"
    Next intI
    lblRow(3).Caption = "总行数"
    txtData(2 * intCol + 1).Text = intRowAll            '总行数
    For intI = 2 To intCol
        txtData(2 * intCol + intI) = "*******"
    Next intI
    If blnTitle Then                                    '有标题
        lblRow(4).Caption = "标题"
        txtData(3 * intCol + 1).Text = "插值结果"
        For intI = 2 To intCol
            txtData(3 * intCol + intI) = "*******"
        Next intI
        intN = 5
    End If
    If blnRowLabel Then                                 '有行标
        For intI = intN To intN + intRow - 1
            lblRow(intI).Caption = "行标" & (intI - intN + 1)
            txtData((intI - 1) * intCol + 1).Text = " "
            For intJ = 2 To intCol
                txtData((intI - 1) * intCol + intJ).Text = "*******"
            Next intJ
        Next intI
        intN = intN + intRow
    End If
    If blnColLabel Then                                 '有列标
        lblRow(intN).Caption = "列标"
        For intI = 1 To intCol
'将新X坐标做为列标,保留一位小数,四舍五入
            sngR = Int(R(1, intI) * 10 + 0.5) / 10
            txtData((intN - 1) * intCol + intI) = sngR
        Next intI
        intN = intN + 1
    End If
    For intI = intN To intRowAll
        lblRow(intI).Caption = "第" & (intI - intN + 1) & "行"
        For intJ = 1 To intCol
            sngR = R(2, intJ)
            txtData((intI - 1) * intCol + intJ) = sngR  '插值后的函数值
        Next intJ
    Next intI
    For intI = 1 To intCol
        lblCol(intI).Caption = "第" & intI & "列"
    Next intI
    FileSave (strRes_Name)
End Sub

'退出
Private Sub cmdExit_Click()
    Unload Me
    frmFileName.Visible = True
End Sub


⌨️ 快捷键说明

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