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

📄 方法3.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 方法3 
   Caption         =   "高斯-塞得尔迭代法"
   ClientHeight    =   7560
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   9810
   LinkTopic       =   "Form3"
   Picture         =   "方法3.frx":0000
   ScaleHeight     =   7560
   ScaleWidth      =   9810
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command4 
      BackColor       =   &H008080FF&
      Caption         =   "清除文本输出"
      Height          =   735
      Left            =   4680
      Style           =   1  'Graphical
      TabIndex        =   9
      Top             =   2520
      Width           =   1575
   End
   Begin VB.PictureBox Picture2 
      Height          =   615
      Left            =   8520
      ScaleHeight     =   555
      ScaleWidth      =   675
      TabIndex        =   6
      Top             =   1800
      Width           =   735
   End
   Begin VB.TextBox Text1 
      Height          =   2295
      Left            =   7080
      MultiLine       =   -1  'True
      TabIndex        =   5
      Top             =   3840
      Width           =   2295
   End
   Begin VB.CommandButton Command3 
      BackColor       =   &H000080FF&
      Caption         =   "高斯-塞德尔迭代法"
      Height          =   735
      Left            =   2640
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   2520
      Width           =   1695
   End
   Begin VB.CommandButton Command2 
      BackColor       =   &H008080FF&
      Caption         =   "打开方程组"
      Height          =   735
      Left            =   120
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   2520
      Width           =   1455
   End
   Begin VB.CommandButton Command1 
      BackColor       =   &H0080FF80&
      Caption         =   "返回主窗口"
      Height          =   615
      Left            =   8400
      Picture         =   "方法3.frx":1D804
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   6840
      Width           =   1335
   End
   Begin VB.Timer Timer1 
      Interval        =   20
      Left            =   960
      Top             =   6720
   End
   Begin VB.PictureBox Picture1 
      Appearance      =   0  'Flat
      AutoRedraw      =   -1  'True
      BackColor       =   &H80000005&
      ForeColor       =   &H80000008&
      Height          =   675
      Left            =   1800
      ScaleHeight     =   645
      ScaleWidth      =   705
      TabIndex        =   0
      Top             =   2520
      Width           =   735
   End
   Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
      Height          =   3015
      Left            =   120
      TabIndex        =   3
      Top             =   3360
      Width           =   6615
      _ExtentX        =   11668
      _ExtentY        =   5318
      _Version        =   393216
      Rows            =   15
      Cols            =   15
      BackColor       =   16776960
      FormatString    =   "^ 序列|^  x1|^  x2|^  x3|^  x4|^  x5|^  x6|^  x7|^  x8|^  x9|^  x10|^     b"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   360
      Top             =   6720
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.Label Label2 
      BackColor       =   &H0000FFFF&
      Caption         =   "输出方程的结果"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   495
      Left            =   7080
      TabIndex        =   8
      Top             =   3240
      Width           =   2415
   End
   Begin VB.Label Label1 
      BackColor       =   &H00C0FFFF&
      Caption         =   "迭代次数为"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   495
      Left            =   6600
      TabIndex        =   7
      Top             =   1920
      Width           =   1815
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   0
      Left            =   1560
      Picture         =   "方法3.frx":1DC46
      Top             =   6600
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   1
      Left            =   2040
      Picture         =   "方法3.frx":1DF50
      Top             =   6600
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   2
      Left            =   2520
      Picture         =   "方法3.frx":1E25A
      Top             =   6600
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   3
      Left            =   3000
      Picture         =   "方法3.frx":1E564
      Top             =   6600
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   4
      Left            =   3480
      Picture         =   "方法3.frx":1E86E
      Top             =   6600
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   5
      Left            =   3960
      Picture         =   "方法3.frx":1EB78
      Top             =   6600
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   6
      Left            =   4440
      Picture         =   "方法3.frx":1EE82
      Top             =   6600
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   7
      Left            =   4920
      Picture         =   "方法3.frx":1F18C
      Top             =   6600
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   8
      Left            =   5400
      Picture         =   "方法3.frx":1F496
      Top             =   6600
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   9
      Left            =   1560
      Picture         =   "方法3.frx":1F7A0
      Top             =   7080
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   10
      Left            =   2040
      Picture         =   "方法3.frx":1FAAA
      Top             =   7080
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   11
      Left            =   2520
      Picture         =   "方法3.frx":1FDB4
      Top             =   7080
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   12
      Left            =   3000
      Picture         =   "方法3.frx":200BE
      Top             =   7080
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   13
      Left            =   3480
      Picture         =   "方法3.frx":203C8
      Top             =   7080
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   14
      Left            =   3960
      Picture         =   "方法3.frx":206D2
      Top             =   7080
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   15
      Left            =   4440
      Picture         =   "方法3.frx":209DC
      Top             =   7080
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   16
      Left            =   4920
      Picture         =   "方法3.frx":20CE6
      Top             =   7080
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Image Image1 
      Height          =   480
      Index           =   17
      Left            =   5400
      Picture         =   "方法3.frx":20FF0
      Top             =   7080
      Visible         =   0   'False
      Width           =   480
   End
End
Attribute VB_Name = "方法3"
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()
方法3.Hide
主窗口.Show
End Sub
Private Sub Command2_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, 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 Command3_Click()
Dim k!, s#, i%, j%, t#, g#
ReDim X(1 To N) As Single
For i = 1 To N
X(i) = InputBox("请输入变量X的初始值")
Next i
k = 0
Do
k = k + 1
g = 0
For i = 1 To N
s = 0
For j = 1 To N
s = s + a(i, j) * X(j)
Next j
t = (b(i) - s + a(i, i) * X(i)) / a(i, i)
g = g + Abs(t - X(i))
X(i) = t
Next i
If g < 0.000001 Then Exit Do
Loop

If k > 100 Then '无法迭代
MsgBox "超出迭代范围!"
Else
Picture2.Print k
End If
For i = 1 To N
   Text1.Text = Text1.Text & "x" & i & "=" & X(i) & vbCrLf
Next i
End Sub

Private Sub Command4_Click()
Picture2.Cls
Text1.Text = ""
End Sub

Private Sub Timer1_Timer()
 Static y As Integer
    y = y + 1: If y = 18 Then y = 0             ' 指定陀螺的某张图片
    Picture1.Picture = Image1(y).Picture        ' 图形框装入某张图片
   方法3.Icon = Image1(y).Picture              ' 窗体的Icon属性装入图片
End Sub

⌨️ 快捷键说明

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