0% found this document useful (0 votes)
28 views3 pages

RAMOS Javier - Pract.09 (Visual)

This document contains the code for a Visual Basic .NET program that calculates the integral of a function using the trapezoidal rule. The code defines variables to store the integral limits, step size, function value, running sum, and result. It contains buttons to run the integration, clear the fields, and exit. On each iteration, it calculates the function value, updates the running sum weighted by the trapezoid rule coefficients, and displays the iteration details and running integral in text boxes and a list.

Uploaded by

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

RAMOS Javier - Pract.09 (Visual)

This document contains the code for a Visual Basic .NET program that calculates the integral of a function using the trapezoidal rule. The code defines variables to store the integral limits, step size, function value, running sum, and result. It contains buttons to run the integration, clear the fields, and exit. On each iteration, it calculates the function value, updates the running sum weighted by the trapezoid rule coefficients, and displays the iteration details and running integral in text boxes and a list.

Uploaded by

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

Public Class Form1

Dim fx As Double
Dim x As Double
Dim h As Double
Dim r As Double
Dim C As Double
Dim a As Double
Dim b As Double
Dim iter As Double
Dim S As Double
Dim n As Double

Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Label2.Click

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles Button1.Click
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
n = Val(TextBox3.Text)
h = (b - a) / n
TextBox4.Text = h
x = a
fx = 3 * x ^ 2 * Math.Sin(x)

Do While iter <= n


x = a + iter * h
If iter = 0 Or iter = n Then
C = 1
ElseIf iter Mod 2 = 0 And iter > 0 And iter < n Then
C = 2
Else
C = 4
End If
fx = 3 * x ^ 2 * Math.Sin(x)
S = S + fx * C
TextBox5.Text = S
r = 1 * h / 3 * S

ListBox1.Items.Add(Format(iter, "00") & (Space(15) &


Format(x, "0.0000") & Space(15) & Format(fx, "0.0000") & Space(15) &
Format(C, "0.0000") & Space(15) & Format(fx * C, "0.0000")))

iter = iter + 1
Loop
TextBox6.Text = r

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
ListBox1.Items.Clear()
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles Button3.Click
End
End Sub
End Class

You might also like