0% found this document useful (0 votes)
27 views2 pages

Contoh VBA

visual basic

Uploaded by

semogaini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Contoh VBA

visual basic

Uploaded by

semogaini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Sub NRaphson()

Dim q, b, s, an, am, h, fh, fha, ht, error As Variant


Dim i As Integer
Call data(q, b, s, an, am, h)
i=1
Range("a9:f50") = " "

Do While i < 40

Call fungsi(q, b, s, an, am, h, fh, fha)


ht = h - fh / fha
error = (ht - h) / h
If Abs(error) < 0.001 Then
Exit Do
Else
Cells(8 + i, 1) = i
Cells(8 + i, 2) = h
Cells(8 + i, 3) = fh
Cells(8 + i, 4) = fha
Cells(8 + i, 5) = ht
Cells(8 + i, 6) = error
h = ht
End If
i=i+1
Loop

End Sub

Sub data(q, b, s, an, am, h)


q = Cells(1, 2)
b = Cells(2, 2)
s = Cells(3, 2)
an = Cells(4, 2)
am = Cells(5, 2)
h = Cells(6, 2)
End Sub

Sub fungsi(q, b, s, an, am, h, fh, fha)


ak = q * an / s ^ 0.5
fh = ((b + am * h) * h) ^ 5 - ak ^ 3 * (b + 2 * h * (1 + am ^ 2) ^ 0.5) ^ 2
fha = ((b + am * h) * h) ^ 4 * 5 * (b + 2 * am * h) _
- ak ^ 3 * (b + 2 * h * (1 + am ^ 2) ^ 0.5) * 2 * 2 * (1 + am ^ 2) ^ 0.5
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub

You might also like