📄 lagrange.frm
字号:
VERSION 5.00
Begin VB.Form lagrange
Caption = "拉格朗日"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "复原"
Height = 375
Left = 3120
TabIndex = 10
Top = 600
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "数据录入"
Height = 375
Left = 3120
TabIndex = 9
Top = 1200
Width = 1215
End
Begin VB.TextBox Text4
Height = 495
Left = 1320
TabIndex = 7
Text = "Text4"
Top = 2040
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "插值"
Height = 375
Left = 3120
TabIndex = 6
Top = 1920
Width = 1215
End
Begin VB.TextBox Text3
Height = 495
Left = 1320
TabIndex = 5
Text = "Text3"
Top = 1320
Width = 1215
End
Begin VB.TextBox Text2
Height = 375
Left = 1320
TabIndex = 2
Text = "Text2"
Top = 720
Width = 1215
End
Begin VB.TextBox Text1
Height = 375
Left = 1320
TabIndex = 0
Text = "Text1"
Top = 120
Width = 1215
End
Begin VB.Label Label4
Caption = "out"
Height = 375
Left = 240
TabIndex = 8
Top = 2040
Width = 495
End
Begin VB.Label Label3
Caption = "y"
Height = 495
Left = 360
TabIndex = 4
Top = 1320
Width = 375
End
Begin VB.Label Label2
Caption = "x"
Height = 255
Left = 360
TabIndex = 3
Top = 720
Width = 495
End
Begin VB.Label Label1
Caption = "n"
Height = 255
Left = 360
TabIndex = 1
Top = 240
Width = 615
End
End
Attribute VB_Name = "lagrange"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim n As Integer
Dim y As Double
Dim k As Integer
Dim xi(0 To 15) As Double
Dim yj(0 To 15) As Double
'Dim i, j As Integer
Static i As Integer
Static j As Integer
Function sun(xx0, xx1, n) '矩形积分
Dim h, i%
h = (xx1 - xx0) / n
Sum = 0: x = xx0
For i = 1 To n
t = Sin(x)
Sum = Sum + t * h
x = x + h
Next i
End Function
Private Sub Command1_Click()
y = 0
k = 0
Lp:
t = 1
For j = 0 To n
t = (x - xi(j)) * t / (xi(k) - xi(j))
y = y + t * yk
If k <> n Then
k = k + 1
End If
Next j
GoTo Lp
Text4.Text = CStr(y)
End Sub
Private Sub Command2_Click()
Text1.Enabled = False
If i < n - 1 Then
xi(i) = Val(Text2.Text)
Print " 你已经录入了" + CStr(i + 1) + "个数据"
i = i + 1
MsgBox xi(i)
Else
MsgBox "error"
End If
'For j = 0 To n
' yj(j) = Val(Text3.Text)
'Print "你已经录入了" + CStr(j + 1) + "个数据"
'Next j
End Sub
Private Sub Command3_Click()
Text1.Enabled = True
Text4.Enabled = True
End Sub
Private Sub Form_Load()
Text1.Text = " "
Text2.Text = " "
Text3.Text = " "
Text4.Text = " "
i = j = 0
n = Val(Text1.Text)
Text4.Enabled = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -