0% found this document useful (0 votes)
6 views1 page

Graphing Function Plotter Code

This document contains code for drawing axes on a graph, handling resizing of the graph, and buttons for plotting a function and resetting the graph. It declares variables for tracking the x and y-axis origins, draws the axes and labels on the graph, and contains event handler code for the plot, reset and resize buttons/events that refresh the graph.

Uploaded by

AR Domingo
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)
6 views1 page

Graphing Function Plotter Code

This document contains code for drawing axes on a graph, handling resizing of the graph, and buttons for plotting a function and resetting the graph. It declares variables for tracking the x and y-axis origins, draws the axes and labels on the graph, and contains event handler code for the plot, reset and resize buttons/events that refresh the graph.

Uploaded by

AR Domingo
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

Private Sub DrawAxes(ByVal g As Graphics)

'Note that intXOrigin and intYOrigin is declared as a field variable (class level)
intXOrigin = [Link] \ 2 'Calculates the x-origin, half of PicDraw Width
intYOrigin = [Link] \ 2 'Claculates the y-origin, half of PicDraw Height

Dim myfont As New Font("Arial", 8, [Link])

[Link]([Link])
[Link]([Link], 0, intYOrigin, [Link], intYOrigin) 'draw x-axis
[Link]([Link], intXOrigin, 0, intXOrigin, [Link]) 'draw y-axis
[Link]("(0, 0)", myfont, [Link], intXOrigin, intYOrigin) 'add label to origin
If blnPlot = False Then
[Link]("This program plots the general function" _
& vbNewLine & "y = (Cx)^(1/N)" _
& vbNewLine & "Please input the appropirate values of C and N" _
& vbNewLine & "to the respective textboxes", myfont, [Link], 0, 0) 'add
instruction
Else
[Link]("graph of the function" _
& vbNewLine & "y = (" & sngC & "x)^(1/" & sngN & ")", _
myfont, [Link], 0, 0) 'adds function label to the graph
End If

End Sub
Private Sub Form1_Resize(sender As Object, e As [Link]) Handles [Link]
[Link]() 'for resizing
End Sub

Private Sub btnPlot_Click(sender As [Link], e As [Link]) Handles


[Link]
Try
sngN = [Link]
sngC = [Link]
If sngC < 0 Then 'just a checker for C
[Link]("The constant, C, should be greater than or equal to zero.")
Else 'if everything is right
blnPlot = True
[Link]()
End If
Catch ex As Exception 'oops, something went wrong. ^_^
[Link]([Link])
End Try
End Sub

Private Sub btnReset_Click(sender As [Link], e As [Link]) Handles


[Link]
'Just to reset everything
blnPlot = False
[Link]()
[Link]()
[Link]()
End Sub
End Class

You might also like