Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleGraph a function with parameters entered by the user using a convenient scale
Keywordsgraph, equation, scale
CategoriesGraphics
 
Use a PictureBox's Scale properties to make a convenient scale. Read the parameter values from TextBoxes. Then use a Do loop to increment the independent variable that determines the function values.
 
Private Sub cmdDraw_Click()
Const PI = 3.14159265
Dim A As Single
Dim B As Single
Dim theta As Single
Dim dtheta As Single

    A = CSng(txtA.Text)
    B = CSng(txtB.Text)
    picGraph.ScaleLeft = 0
    picGraph.ScaleWidth = 4 * PI
    picGraph.ScaleTop = 2
    picGraph.ScaleHeight = -4
    picGraph.AutoRedraw = True

    theta = 0
    picGraph.Cls
    picGraph.CurrentX = theta
    picGraph.CurrentY = Sin(A * theta) + Sin(B * theta)

    dtheta = 4 * PI / picGraph.ScaleX(picGraph.ScaleWidth, _
        picGraph.ScaleMode, vbPixels)
    Do While theta <= 4 * PI + dtheta / 2
        picGraph.Line -(theta, Sin(A * theta) + Sin(B * _
            theta))
        theta = theta + dtheta
    Loop
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated