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

📄 插值计算.frm

📁 Lagrange算法程序
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   7530
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   7455
   LinkTopic       =   "Form1"
   ScaleHeight     =   7530
   ScaleWidth      =   7455
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "退出程序"
      Height          =   495
      Left            =   4800
      TabIndex        =   6
      Top             =   6960
      Width           =   1675
   End
   Begin VB.CommandButton Command1 
      Caption         =   "清除并初始化"
      Height          =   495
      Left            =   600
      TabIndex        =   5
      Top             =   6960
      Width           =   1575
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   3840
      TabIndex        =   3
      Top             =   5520
      Width           =   1935
   End
   Begin VB.CommandButton cmdJS 
      Caption         =   "点击进行插值计算"
      Height          =   495
      Left            =   2160
      TabIndex        =   2
      Top             =   6480
      Width           =   2655
   End
   Begin VB.CommandButton cmdSY 
      Caption         =   "输入 Y(i)"
      Height          =   495
      Left            =   5280
      TabIndex        =   1
      Top             =   4680
      Width           =   1215
   End
   Begin VB.CommandButton cmdSX 
      Caption         =   "输入 X(i)"
      Height          =   495
      Left            =   960
      TabIndex        =   0
      Top             =   4680
      Width           =   1215
   End
   Begin VB.Label Label1 
      Caption         =   "请输入需要进行插值计算的 x:"
      Height          =   495
      Left            =   1320
      TabIndex        =   4
      Top             =   5640
      Width           =   2535
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
 Option Explicit
 Dim x() As Single, y() As Single
 Dim n As Integer, m As Integer
 
 Private Sub cmdJS_Click()
  Dim Ln As Single, li As Single
  Dim i As Integer, j As Integer
  Dim x0 As Single
  x0 = Val(Text1.Text)
  Ln = 0
  For i = 0 To UBound(x)
    li = 1
    For j = 0 To UBound(x)
       If j <> i Then
         li = li * (x0 - x(j)) / (x(i) - x(j))        '计算插值基函数li
       End If
    Next j
    Ln = Ln + li * y(i)                               '插值多项式Ln的计算
  Next i
  Print "计算结果为:" & Ln
End Sub

Private Sub cmdSX_Click()
  ReDim Preserve x(0 To n)
  x(n) = Val(InputBox("请输入X(" & n & ")"))          '输入x(i)数组并有规律的打印在窗体上
  CurrentX = 0
  CurrentY = 200 * n
  Print Space(10) & "X(" & n & ") =" & x(n)
  n = n + 1
End Sub

Private Sub cmdSY_Click()
  ReDim Preserve y(0 To m)
  y(m) = Val(InputBox("请输入Y(" & m & ")"))           '输入y(i)数组并有规律的打印在窗体上
  CurrentX = 0
  CurrentY = 200 * m
  Print Space(60) & "Y(" & m & ") =" & y(m)
  m = m + 1
End Sub

Private Sub Command1_Click()
  Form1.Cls                      '清楚窗体上的数以及文本框中的值,为下一次运算作准备(即m、n初始话)
  Text1.Text = ""
  m = 0
  n = 0
End Sub

Private Sub Command2_Click()
  Unload Me
End Sub

⌨️ 快捷键说明

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