VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   6045
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   9495
   LinkTopic       =   "Form1"
   ScaleHeight     =   10.663
   ScaleMode       =   7  'Centimeter
   ScaleWidth      =   16.748
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command6 
      Caption         =   "y = cos (x)"
      Height          =   375
      Left            =   6120
      TabIndex        =   7
      Top             =   3000
      Width           =   3255
   End
   Begin VB.CommandButton Command5 
      Caption         =   "y = sin (x)"
      Height          =   375
      Left            =   6120
      TabIndex        =   6
      Top             =   2520
      Width           =   3255
   End
   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     =   10.478
      ScaleMode       =   7  'Centimeter
      ScaleWidth      =   10.478
      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
Dim oldx As Double
Dim oldy As Double
Dim bStarted As Boolean

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
    bStarted = False
    For i = -1000 To 1000 Step 0.01
        x = i
        y = -1 * (x ^ 2)
        If bStarted Then
            'only start drawing after the first pass
            'so we can seed the oldx and oldy values
            pic1.Line (x0 + oldx, y0 + oldy)-(x0 + x, y0 + y)
        End If
        bStarted = True
        oldx = x
        oldy = y
    Next i
End Sub
Private Sub Command2_Click()
    '2. y= sqr(x)
    bStarted = False
    For i = -1000 To 1000 Step 0.01
        y = -1 * i
        x = (y ^ 2)
        If bStarted Then
            'only start drawing after the first pass
            'so we can seed the oldx and oldy values
            pic1.Line (x0 + oldx, y0 + oldy)-(x0 + x, y0 + y)
        End If
        bStarted = True
        oldx = x
        oldy = y
    Next i
End Sub
Private Sub Command3_Click()
    '3. y=|x| (absolute value)
    bStarted = False
    For i = -1000 To 1000 Step 0.01
        x = i
        y = -1 * (Abs(x))
        If bStarted Then
            'only start drawing after the first pass
            'so we can seed the oldx and oldy values
            pic1.Line (x0 + oldx, y0 + oldy)-(x0 + x, y0 + y)
        End If
        bStarted = True
        oldx = x
        oldy = y
    Next i
End Sub
Private Sub Command4_Click()
    '4. x^2 + y^2 = 1 (circle with 1 radius)
    pic1.Circle (x0, y0), 1
End Sub
Private Sub Command5_Click()
    ' 5. y = sin (x)
    bStarted = False
    For i = -1000 To 1000 Step 0.01
        x = i
        y = Sin(x)
        If bStarted Then
            'only start drawing after the first pass
            'so we can seed the oldx and oldy values
            pic1.Line (x0 + oldx, y0 + oldy)-(x0 + x, y0 + y)
        End If
        bStarted = True
        oldx = x
        oldy = y
    Next i
End Sub
Private Sub Command6_Click()
    ' 6. y = cos (x)
    bStarted = False
    For i = -1000 To 1000 Step 0.01
        x = i
        y = Cos(x)
        If bStarted Then
            'only start drawing after the first pass
            'so we can seed the oldx and oldy values
            pic1.Line (x0 + oldx, y0 + oldy)-(x0 + x, y0 + y)
        End If
        bStarted = True
        oldx = x
        oldy = y
    Next i
End Sub
