VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   6045
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   9555
   LinkTopic       =   "Form1"
   ScaleHeight     =   403
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   637
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command4 
      Caption         =   "x^2 + y^2 = 1 (circle with 1 radius)"
      Height          =   375
      Left            =   6120
      TabIndex        =   5
      Top             =   2040
      Width           =   3255
   End
   Begin VB.CommandButton Command3 
      Caption         =   "y=|x| (absolute value)"
      Height          =   375
      Left            =   6120
      TabIndex        =   4
      Top             =   1560
      Width           =   3255
   End
   Begin VB.CommandButton Command2 
      Caption         =   "y= sqr(x)"
      Height          =   375
      Left            =   6120
      TabIndex        =   3
      Top             =   1080
      Width           =   3255
   End
   Begin VB.CommandButton Command1 
      Caption         =   "y = x ^ 2"
      Height          =   375
      Left            =   6120
      TabIndex        =   2
      Top             =   600
      Width           =   3255
   End
   Begin VB.CommandButton cmdDrawAxis 
      Caption         =   "Draw Axis"
      Height          =   375
      Left            =   6120
      TabIndex        =   1
      Top             =   120
      Width           =   3255
   End
   Begin VB.PictureBox pic1 
      AutoRedraw      =   -1  'True
      Height          =   6000
      Left            =   0
      ScaleHeight     =   396
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   396
      TabIndex        =   0
      Top             =   0
      Width           =   6000
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim i As Double
Dim x As Double
Dim y As Double
Dim x0 As Double
Dim y0 As Double

Private Sub Form_Load()
' We will draw the axis in the center of the picture box
' So 0,0 will actually be halfway down the picture box and
' halfway across the picture box or . . .
' pic1.Width / 2, pic1.Height / 2
    
    x0 = pic1.Width / 2
    y0 = pic1.Height / 2
End Sub
Private Sub cmdDrawAxis_Click()
    pic1.Cls
    ' Draw X axis
    pic1.Line (0, pic1.Height / 2)-(pic1.Width, pic1.Height / 2)
    ' Draw Y axis
    pic1.Line (pic1.Width / 2, 0)-(pic1.Width / 2, pic1.Height)
End Sub
Private Sub Command1_Click()
    '1. y=x^2
    ' hmmmm, about 1000 points should be enough
    ' I am dividing the values by 10 to scale the graph so
    ' it is clearly visible
    For i = -1000 To 1000 Step 0.01
        x = i / 10
        y = -1 * ((x ^ 2) / 10)
        pic1.Circle (x0 + x, y0 + y), 1     ' draw a point
    Next i
End Sub
Private Sub Command2_Click()
    '2. y= sqr(x)
    ' or y^2 = x
    ' hmmmm, about 1000 points should be enough
    ' I am dividing the values by 10 to scale the graph so
    ' it is clearly visible
    For i = -1000 To 1000 Step 0.01
        y = -1 * (i / 10)
        x = ((y ^ 2) / 10)
        pic1.Circle (x0 + x, y0 + y), 1     ' draw a point
    Next i
End Sub
Private Sub Command3_Click()
    '3. y=|x| (absolute value)
    ' hmmmm, about 1000 points should be enough
    For i = -10000 To 10000 Step 0.1
        x = i / 10
        y = -1 * (Abs(x))
        pic1.Circle (x0 + x, y0 + y), 1     ' draw a point
    Next i
End Sub
Private Sub Command4_Click()
    '4. x^2 + y^2 = 1 (circle with 1 radius)
    ' well, we really need to solve for y
    ' y^2 = 1-x^2
    ' y = (1-x^2)^.5
    
    'draw bottom of circle
    For i = -100 To 100 Step 0.01
        x = i
        y = (((10000 - (x ^ 2)) ^ 0.5))
        pic1.Circle (x0 + x, y0 + y), 1     ' draw a point
    Next i
    'draw top of circle
    For i = -100 To 100 Step 0.01
        x = i
        y = -1 * (((10000 - (x ^ 2)) ^ 0.5))
        pic1.Circle (x0 + x, y0 + y), 1     ' draw a point
    Next i
End Sub
