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

📄 逐步回归f3.frm

📁 <VB数理统计实用算法>书中的算法源程序
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmContinue 
   Appearance      =   0  'Flat
   BackColor       =   &H80000005&
   Caption         =   "逐步回归"
   ClientHeight    =   8010
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7425
   LinkTopic       =   "Form1"
   ScaleHeight     =   8010
   ScaleWidth      =   7425
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox txtData 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      Height          =   270
      Index           =   0
      Left            =   5160
      TabIndex        =   12
      Text            =   "txtData"
      Top             =   0
      Visible         =   0   'False
      Width           =   855
   End
   Begin VB.TextBox txtV 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      Height          =   270
      Index           =   0
      Left            =   2040
      TabIndex        =   8
      Top             =   1440
      Width           =   1575
   End
   Begin VB.TextBox txtFile 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      Height          =   270
      Left            =   480
      TabIndex        =   5
      Text            =   "txtFile"
      Top             =   720
      Width           =   6375
   End
   Begin VB.CommandButton cmdCalculate 
      Caption         =   "计  算"
      Height          =   375
      Left            =   3720
      TabIndex        =   3
      Top             =   0
      Width           =   1215
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "结  束"
      Height          =   375
      Left            =   2520
      TabIndex        =   2
      Top             =   0
      Width           =   1215
   End
   Begin VB.CommandButton cmdSmo 
      Caption         =   "平  滑"
      Height          =   375
      Left            =   1320
      TabIndex        =   1
      ToolTipText     =   "由原有的入选自变量值求函数值并存盘"
      Top             =   0
      Width           =   1215
   End
   Begin VB.CommandButton cmdPre 
      Caption         =   "预  测"
      Height          =   375
      Left            =   0
      TabIndex        =   0
      ToolTipText     =   "给定入选自变量计算函数值"
      Top             =   0
      Width           =   1335
   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            =   6600
      TabIndex        =   14
      Top             =   0
      Visible         =   0   'False
      Width           =   735
   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            =   6000
      TabIndex        =   13
      Top             =   0
      Visible         =   0   'False
      Width           =   615
   End
   Begin VB.Label lblR 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      BorderStyle     =   1  'Fixed Single
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   5400
      TabIndex        =   11
      Top             =   1680
      Width           =   1455
   End
   Begin VB.Label Label3 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "(Y = ???)"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   5400
      TabIndex        =   10
      Top             =   1440
      Width           =   1455
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "预测的结果"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   5040
      TabIndex        =   9
      Top             =   1200
      Width           =   2175
   End
   Begin VB.Label lblV 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      BorderStyle     =   1  'Fixed Single
      ForeColor       =   &H80000008&
      Height          =   255
      Index           =   0
      Left            =   1080
      TabIndex        =   7
      Top             =   1450
      Width           =   975
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "在下列文本框(无*****者)键入选中的自变量值"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   120
      TabIndex        =   6
      Top             =   1200
      Width           =   4575
   End
   Begin VB.Label lblFile 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "保存平滑后的数据文件(可以改变)"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   1680
      TabIndex        =   4
      Top             =   480
      Width           =   4575
   End
End
Attribute VB_Name = "frmContinue"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'逐步回归
Option Explicit
Dim strSmoFile As String, I As Integer, J As Integer
Dim intFileNumber As Integer, vntA As Variant

Private Sub Form_Load()
    Me.Top = 0
    cmdCalculate.Visible = False
    lblFile.Visible = False: txtFile.Visible = False
    lblV(0).Visible = False: txtV(0).Visible = False
    Label1.Visible = False: Label2.Visible = False
    Label3.Visible = False: lblR.Visible = False
    intFileNumber = FreeFile            '取得空闲的文件号码
    Open strFileName For Input As intFileNumber '打开文件
'形成文本框数组,但不在窗体上显示
    For I = 1 To intRowAll
        For J = 1 To intCol
            Input #intFileNumber, vntA
            Load txtData((I - 1) * intCol + J)
            txtData((I - 1) * intCol + J).Text = vntA
        Next J
    Next I
'形成上部标签,但不在窗体上显示
    For I = 1 To intCol
        Input #intFileNumber, vntA
        Load lblCol(I)
        lblCol(I).Caption = vntA
    Next I
'形成左边标签,但不在窗体上显示
    For I = 1 To intRowAll
        Input #intFileNumber, vntA
        Load lblRow(I)
        lblRow(I).Caption = vntA
    Next I
    Close
End Sub

'预测
Private Sub cmdPre_Click()
    On Error Resume Next
    Dim sngH As Single
    cmdCalculate.Caption = "计  算"
    cmdCalculate.Visible = True
    lblFile.Visible = False: txtFile.Visible = False
    Label1.Visible = True
    sngH = lblV(0).Height
    For I = 1 To m
        Load lblV(I): Load txtV(I)
        lblV(I).Move lblV(0).Left, lblV(0).Top + (I - 1) * sngH
        lblV(I).Caption = "X" & Str(I)
        lblV(I).Visible = True
        txtV(I).Move txtV(0).Left, txtV(0).Top + (I - 1) * sngH
        If b(I) = 0 Then txtV(I).Text = "*****" Else txtV(I).Text = " "
        txtV(I).Visible = True
    Next I
    txtV(1).SetFocus
End Sub

'平滑
Private Sub cmdSmo_Click()
    On Error Resume Next
    cmdCalculate.Caption = "保  存"
    cmdCalculate.Visible = True
    lblV(0).Visible = False: txtV(0).Visible = False
    Label1.Visible = False: Label2.Visible = False
    Label3.Visible = False: lblR.Visible = False
    For I = 1 To m
        lblV(I).Visible = False: txtV(I).Visible = False
    Next I
    txtFile.Text = frmFileName.Dir1.Path & _
                   "\平滑_" & frmFileName.File1.FileName
    lblFile.Visible = True
    txtFile.Visible = True
End Sub

'“计算”或“保存”
Private Sub cmdCalculate_Click()
    Dim intNumber As Integer, vntA As Variant
    Dim sngY As Single
    If cmdCalculate.Caption = "保  存" Then GoTo LSave
    Label2.Visible = True: Label3.Visible = True
    lblR.Visible = True
    sngY = b(0)
    For I = 1 To m
        If txtV(I).Text = " " Then
            MsgBox "必须在文本框内填入数据后再计算!"
            Exit Sub
        End If
        sngY = sngY + b(I) * Val(txtV(I))           '预测
    Next I
    lblR.Caption = Str(sngY)
    Exit Sub
LSave:
'将平滑结果保存到数据文件
    For I = 1 To intRow
        sngY = b(0)
        For J = 1 To m
            If b(J) <> 0 Then
                sngY = sngY + b(J) * xy(I, J)       '平滑计算
            End If
        Next J
        txtData((intRowAll - intRow + I - 1) * intCol + intCol) = Str(sngY)
    Next I
    MsgBox "现在存盘,请耐心等待!"
    intNumber = FreeFile                            '取得空闲的文件号
    Open txtFile.Text For Output As intNumber       '打开文件
'保存数据
    txtData(3 * intCol + 1) = "回归平滑"
    For I = 1 To intRowAll
        For J = 1 To intCol
            Write #intNumber, txtData((I - 1) * intCol + J);
        Next J
    Next I
'保存上部标签
    For I = 1 To intCol
        Write #intNumber, lblCol(I).Caption;
    Next I
'保存左边标签
    For I = 1 To intRowAll
        Write #intNumber, lblRow(I).Caption;
    Next I
    Close                                           '关闭文件
    MsgBox "存盘完成,请继续进行!"
End Sub

Private Sub txtV_Change(Index As Integer)
    lblR.Caption = ""
End Sub

'结束
Private Sub cmdExit_Click()
    Unload Me
    End
End Sub


⌨️ 快捷键说明

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