This is a program that enables the user to input the coefficients of a cubic function and draw its graph. The cubic function takes the form f(x)=ax^{3}+bx^{2}+cx+d. We need to create the cubic function with some modifications and the coordinates in computer screen starts from top left, therefore instead of x we used a certain number to minus x. As we define the width of the graph as 10, so we use 5x so that the graph starts plotting from the center. In VB, the cubic function takes the following form:
Private Function f(x As Variant)
f = a * (5  x) ^ 3 + b * (5  x) ^ 2 + c * (5  x) + d
End Function
To draw the graph, we use builtin functionPSet.
In this program, you need to insert four text boxes for the user to enter the four coefficients, a picture box and two command buttons, one is to draw the graph and the other one to clear the inputs. Name the picture box as pic_graph, the draw button cmd_draw and the clear button as cmd_Clear.
The CodeDim a, b, c, d As Integer 

Copyright ® 2008 Dr.Liew Voon Kiong . All rights reserved Contact: admin@vbtutor.net