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

📄 方法4.frm

📁 解各类线性方程的方法以及相关的编程! 希望可以采用我这个工程软件,我可是花了好多的心血!
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form 方法4 
   AutoRedraw      =   -1  'True
   Caption         =   "改进的平方根法"
   ClientHeight    =   6795
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   9120
   LinkTopic       =   "Form1"
   Picture         =   "方法4.frx":0000
   ScaleHeight     =   6795
   ScaleWidth      =   9120
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command3 
      BackColor       =   &H00C0C000&
      Caption         =   "清楚输入结果"
      Height          =   615
      Left            =   4200
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   3840
      Width           =   1575
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   0
      Top             =   6240
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.CommandButton Command4 
      BackColor       =   &H0000C000&
      Caption         =   "返回主窗口"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   7440
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   6120
      Width           =   1455
   End
   Begin VB.CommandButton Command2 
      BackColor       =   &H0000FF00&
      Caption         =   "改进平方根法解"
      Height          =   615
      Left            =   2160
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   3840
      Width           =   1575
   End
   Begin VB.CommandButton Command1 
      BackColor       =   &H00C0C0FF&
      Caption         =   "打开方程组"
      Height          =   615
      Left            =   120
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   3840
      Width           =   1575
   End
   Begin VB.PictureBox Picture1 
      BackColor       =   &H00FFFF80&
      Height          =   3015
      Left            =   6720
      ScaleHeight     =   2955
      ScaleWidth      =   2115
      TabIndex        =   0
      Top             =   1440
      Width           =   2175
   End
   Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
      Height          =   3615
      Left            =   120
      TabIndex        =   4
      Top             =   120
      Width           =   6495
      _ExtentX        =   11456
      _ExtentY        =   6376
      _Version        =   393216
      Rows            =   15
      Cols            =   15
      BackColor       =   8454016
      FormatString    =   "^ 序列|^  x1|^  x2|^  x3|^  x4|^  x5|^  x6|^  x7|^  x8|^  x9|^  x10|^     b"
   End
End
Attribute VB_Name = "方法4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim a(20, 20) As Single, b() As Single, X() As Single
Dim i As Integer, N As Integer, j As Integer

Private Sub Command1_Click()
Dim FileName As String
Dim Astr As String
On Error GoTo errhandle
CommonDialog1.InitDir = App.Path '设置初始路径   数据导入
CommonDialog1.FileName = "" '清除文件名
CommonDialog1.ShowOpen '显示“打开”对话框
FileName = CommonDialog1.FileName '保存文件名
If Len(CommonDialog1.FileName) > 0 Then
    'File = FreeFile() '获得可用文件号
    Open FileName For Input As #1 '打开文件
End If
i = 0: N = 0: j = 0: Dim Line1 As String
MousePointer = 11
Do While EOF(1) = False
    N = N + 1
    Line Input #1, Line1
Loop
ReDim b(N): ReDim X(N)

MSFlexGrid1.Cols = N + 2: MSFlexGrid1.Rows = N + 1
Close #1
Dim Forstr As String
Forstr = "序列"
For i = 1 To N
   Forstr = Forstr & "|^  x" & i
   MSFlexGrid1.TextMatrix(i, 0) = i
Next i
Forstr = Forstr & "|^   b"
MSFlexGrid1.FormatString = Forstr


Open FileName For Input As #2 '打开文件
Do While EOF(2) = False
     j = j + 1
     For i = 1 To N
        Input #2, Astr ' 分别输入各数据
        a(j, i) = Astr
        MSFlexGrid1.TextMatrix(j, i) = Astr
     Next i
     Input #2, Astr
     b(j) = Astr
     MSFlexGrid1.TextMatrix(j, N + 1) = Astr
Loop
Close #2

errhandle:
    MousePointer = 0
Exit Sub
MousePointer = 0

End Sub
Private Sub Command2_Click()
Dim y() As Single, s!, k%, j%, i%, l() As Single
ReDim y(1 To N) As Single
ReDim X(1 To N) As Single
ReDim l(1 To N, 1 To N) As Single
For j = 1 To N
    s = 0
    For k = 1 To j - 1
        s = s + l(j, k) ^ 2
    Next k
    l(j, j) = Sqr(a(j, j) - s)
    For i = j + 1 To N
        s = 0
        For k = 1 To j - 1
            s = s + l(i, k) * l(j, k)
        Next k
        l(i, j) = (a(i, j) - s) / l(j, j)
    Next i
Next j
For i = 1 To N
    s = 0
    For k = 1 To i - 1
        s = s + l(i, k) * y(k)
    Next k
    y(i) = (b(i) - s) / l(i, i)
Next i
For i = N To 1 Step -1
    s = 0
    For k = i + 1 To N
        s = s + l(k, i) * X(k)
    Next k
    X(i) = (y(i) - s) / l(i, i)
Next i
For i = 1 To N
    Picture1.Print "x(" & i & ")="; Format(X(i), "0.00")
Next i
End Sub


Private Sub Command3_Click()
Picture1.Cls
End Sub

Private Sub Command4_Click()
主窗口.Show
方法4.Hide
End Sub

⌨️ 快捷键说明

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