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

📄 form1.frm

📁 用VB程序编写的数值分析高斯消去法求解线性方程组
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   6090
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   7605
   LinkTopic       =   "Form1"
   ScaleHeight     =   6090
   ScaleWidth      =   7605
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox Text3 
      Height          =   495
      Left            =   2640
      TabIndex        =   9
      Top             =   3000
      Width           =   1455
   End
   Begin VB.TextBox Text2 
      Height          =   495
      Left            =   2640
      TabIndex        =   7
      Top             =   1800
      Width           =   1455
   End
   Begin VB.CommandButton Command3 
      Caption         =   "退出"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   5520
      TabIndex        =   5
      Top             =   4440
      Width           =   1095
   End
   Begin VB.CommandButton Command2 
      Caption         =   "下一次计算"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   3120
      TabIndex        =   4
      Top             =   4440
      Width           =   1335
   End
   Begin VB.PictureBox Picture1 
      Height          =   3135
      Left            =   4440
      ScaleHeight     =   3075
      ScaleWidth      =   2475
      TabIndex        =   3
      Top             =   480
      Width           =   2535
   End
   Begin VB.TextBox Text1 
      Height          =   495
      Left            =   2640
      TabIndex        =   1
      Top             =   480
      Width           =   1455
   End
   Begin VB.CommandButton Command1 
      Caption         =   "输入矩阵"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   840
      TabIndex        =   0
      Top             =   4440
      Width           =   1455
   End
   Begin VB.Label Label3 
      Caption         =   "最大迭代次数"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   360
      TabIndex        =   8
      Top             =   3120
      Width           =   1575
   End
   Begin VB.Label Label2 
      Caption         =   "输入容许误差"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   360
      TabIndex        =   6
      Top             =   1920
      Width           =   1935
   End
   Begin VB.Label Label1 
      Caption         =   "请输入方阵的维数"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   360
      TabIndex        =   2
      Top             =   600
      Width           =   1935
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim a!(), b!(), x!(), y!(), n1%, n%, k%, ep!, e!, s!, i%, j%
n = Val(Text1.Text)
ReDim a(n, n), b(n), x(n), y(n)
For i = 1 To n
For j = 1 To n
a(i, j) = InputBox("请输入a(" & i & "," & j & "):", "练习")
   Next j
   b(i) = InputBox("请输入b(" & i & "):", "练习")
Next i

ep = Val(Text2.Text)   '容许误差
n1 = Val(Text3.Text)   '输入迭代次数

For i = 1 To n
x(i) = 0
Next i
k = 0

Do      '迭代格式
k = k + 1
   For i = 1 To n
   s = 0
      For j = 1 To n
         If i <> j Then
         s = s + a(i, j) * x(j)
         End If
      Next j
   y(i) = (b(i) - s) / a(i, i)
   Next i
   
e = 0
For i = 1 To n
If Abs(y(i) - x(i)) > e Then
e = Abs(y(i) - x(i))
End If
Next i

If e < ep Then
For i = 1 To n
Picture1.Print "x("; j; i; ")="; y(i)
Next i
Exit Sub

Else
For i = 1 To n
x(i) = y(i)
Next i
End If
Loop Until k = n1
Picture1.Print "失败"
End Sub

Private Sub Command2_Click()
Text1.Text = " "
Text2.Text = " "
Text3.Text = " "
End Sub

Private Sub Command3_Click()
End
End Sub

⌨️ 快捷键说明

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