?? 一元線性f3.frm
字號:
VERSION 5.00
Begin VB.Form frmContinue
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "一元線性回歸"
ClientHeight = 2085
ClientLeft = 60
ClientTop = 345
ClientWidth = 7425
LinkTopic = "Form1"
ScaleHeight = 2085
ScaleWidth = 7425
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox txtData
Height = 270
Index = 0
Left = 5040
TabIndex = 10
Top = 0
Visible = 0 'False
Width = 495
End
Begin VB.TextBox txtV
Alignment = 2 'Center
Appearance = 0 'Flat
Height = 270
Left = 1800
TabIndex = 7
Top = 1440
Width = 1455
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 lblY
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "Y="
BeginProperty Font
Name = "宋體"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 255
Left = 4680
TabIndex = 14
Top = 1440
Width = 615
End
Begin VB.Label lblV
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "X ="
BeginProperty Font
Name = "宋體"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 255
Left = 1080
TabIndex = 13
Top = 1440
Width = 615
End
Begin VB.Label lblCol
Caption = "lblCol"
Height = 255
Index = 0
Left = 6360
TabIndex = 12
Top = 0
Visible = 0 'False
Width = 735
End
Begin VB.Label lblRow
Caption = "lblRow"
Height = 255
Index = 0
Left = 5640
TabIndex = 11
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 = 9
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 = 8
Top = 1200
Width = 2175
End
Begin VB.Label Label1
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "自變量值"
ForeColor = &H80000008&
Height = 255
Left = 1200
TabIndex = 6
Top = 1200
Width = 2415
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()
cmdCalculate.Visible = False
lblFile.Visible = False: txtFile.Visible = False
lblV.Visible = False: txtV.Visible = False
Label1.Visible = False: Label2.Visible = False
lblY.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: lblV.Visible = True: txtV.Visible = True
End Sub
'平滑
Private Sub cmdSmo_Click()
On Error Resume Next
cmdCalculate.Caption = "保 存"
cmdCalculate.Visible = True
lblV.Visible = False: txtV.Visible = False
Label1.Visible = False: Label2.Visible = False
lblY.Visible = False: lblR.Visible = False
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: lblY.Visible = True: lblR.Visible = True
If txtV.Text = " " Then
MsgBox "必須在文本框內填入數據后再計算!"
Exit Sub
End If
sngY = b0 + b1 * Val(txtV)
lblR.Caption = Str(sngY)
Exit Sub
LSave:
For I = 1 To intCol
sngY = b0 + b1 * x(I)
txtData((intRowAll - 1) * intCol + I) = 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()
lblR.Caption = ""
End Sub
'結束
Private Sub cmdExit_Click()
Unload Me
End
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -