📄 zbrent.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "msflxgrd.ocx"
Begin VB.Form frmZbrent
Caption = "Prueba de Zbrent"
ClientHeight = 4440
ClientLeft = 60
ClientTop = 345
ClientWidth = 7260
LinkTopic = "Form1"
ScaleHeight = 4440
ScaleWidth = 7260
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton cmdSalir
Caption = "Salir"
Height = 375
Left = 6000
TabIndex = 2
Top = 600
Width = 1095
End
Begin MSFlexGridLib.MSFlexGrid msgResultados
Height = 4215
Left = 360
TabIndex = 1
Top = 120
Width = 5415
_ExtentX = 9551
_ExtentY = 7435
_Version = 393216
End
Begin VB.CommandButton cmdCalcular
Caption = "Calcular"
Height = 375
Left = 6000
TabIndex = 0
Top = 120
Width = 1095
End
End
Attribute VB_Name = "frmZbrent"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdCalcular_Click()
Const n As Long = 100
Const NBMAX As Integer = 20
Const x1 As Single = 1#
Const x2 As Single = 50#
Dim i As Integer, nb As Integer
Dim tol As Single, root() As Double
Dim xb1() As Double, xb2() As Double
Dim xb1i As Single, xb2i As Single
nb = NBMAX
ReDim xb1(1 To NBMAX), xb2(1 To NBMAX), root(1 To NBMAX)
zbrak x1, x2, n, xb1, xb2, nb
For i = 1 To nb
tol = 0.000001 * (xb1(i) + xb2(i)) / 2#
xb1i = xb1(i)
xb2i = xb2(i)
root(i) = zbrent(xb1i, xb2i, tol)
Next i
PresentarGrid msgResultados, nb, xb1, xb2, root()
End Sub
Private Sub PresentarGrid(ByVal msg As MSFlexGrid, ByVal n As Integer, _
ByRef x() As Double, ByRef y() As Double, ByRef z() As Double)
Dim i As Integer
With msg
.Rows = n + 1
.Cols = 4
.TextMatrix(0, 0) = "raiz"
.TextMatrix(0, 1) = "xb1"
.TextMatrix(i, 2) = "xb2"
.TextMatrix(i, 3) = "zbrent"
.ColWidth(3) = 1600
For i = 1 To n
.TextMatrix(i, 0) = i
.TextMatrix(i, 1) = x(i)
.TextMatrix(i, 2) = y(i)
.TextMatrix(i, 3) = z(i)
Next i
End With
End Sub
Private Sub cmdSalir_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -