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

RAMOS Javier - Pract.08 (Visual)

This document contains the code for a Visual Basic .NET program that uses the trapezoidal rule to approximate the integral of a function between two bounds. The program takes user input for the bounds and number of intervals, calculates the integral at each step, and displays the results. It initializes variables, performs the integration loop, and allows the user to clear or exit the program.

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)
40 views2 pages

RAMOS Javier - Pract.08 (Visual)

This document contains the code for a Visual Basic .NET program that uses the trapezoidal rule to approximate the integral of a function between two bounds. The program takes user input for the bounds and number of intervals, calculates the integral at each step, and displays the results. It initializes variables, performs the integration loop, and allows the user to clear or exit the program.

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/ 2

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 m As Double
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)
m = Val(TextBox3.Text)
h = (b - a) / m
TextBox4.Text = h
x = a
fx = Math.Abs(3 * x ^ 2 * Math.Sin(x))

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


"0.0000") & Space(10) & Format(fx, "0.0000") & Space(10) & Format(C,
"0.0000") & Space(10) & Format(fx * C, "0.0000")))

Do While iter <= m

fx = Math.Abs(3 * x ^ 2 * Math.Sin(x))
x = a + iter * h
If iter = 0 Or iter = m Then
C = 0.5
Else
C = 1
End If
fx = Math.Abs(3 * x ^ 2 * Math.Sin(x))
S = S + fx * C
TextBox6.Text = S
R = S * h
ListBox1.Items.Add(Format(iter, "00") & (Space(10) &
Format(x, "0.0000") & Space(10) & Format(fx, "0.0000") & Space(10) &
Format(C, "0.0000") & Space(10) & Format(fx * C, "0.0000")))

iter = iter + 1

Loop
TextBox5.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