You are on page 1of 2

Objective:

To get familiar with Visual Basics various function and syntax.


To get familiar with how to plot in Visual Basic.

STEPS:
In this experiment we have learned how to plot graph in Visual basic. Steps are following

By selecting Windows Application Form, a panel has been selected and docked into the
form.
Going to properties then clicking Event and Resize has been selected.
A program is written which produces a Sin^2x graph and then Resize is used to
maintain the shape in any form of the window.

CODE:
Plotting a Sin^2x Graph using Visual Basic
Imports System.Math
Public Class Form1
Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles
Panel1.Paint
Dim y(1000) As Single
Dim yPoints(1000) As PointF
For i = 0 To y.Length - 1
y(i) = 100 * (Sin(i * 2 * PI / 100)) ^ 2
yPoints(i) = New PointF(i, Panel1.Height / 2 - y(i))
Next
e.Graphics.DrawCurve(Pens.Red, yPoints)
End Sub
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As EventArgs) Handles
MyBase.Resize
Panel1.Refresh()
End Sub
End Class
OUTPUT:

You might also like