home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form Form1
- Caption = "Function Graphs"
- ClientHeight = 4500
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 6855
- LinkTopic = "Form1"
- ScaleHeight = 4500
- ScaleWidth = 6855
- StartUpPosition = 3 'Windows Default
- Begin VB.CommandButton Command3
- Caption = "Draw both functions"
- BeginProperty Font
- Name = "Tahoma"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 405
- Left = 4575
- TabIndex = 3
- Top = 3915
- Width = 2085
- End
- Begin VB.CommandButton Command2
- Caption = "Draw second function"
- BeginProperty Font
- Name = "Tahoma"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 405
- Left = 2385
- TabIndex = 2
- Top = 3915
- Width = 2085
- End
- Begin VB.CommandButton Command1
- Caption = "Draw first function"
- BeginProperty Font
- Name = "Tahoma"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 405
- Left = 210
- TabIndex = 1
- Top = 3915
- Width = 2085
- End
- Begin VB.PictureBox Picture1
- BackColor = &H00FFFFFF&
- Height = 3480
- Left = 165
- ScaleHeight = 228
- ScaleMode = 3 'Pixel
- ScaleWidth = 430
- TabIndex = 0
- Top = 135
- Width = 6510
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Function FunctionEval1(ByVal X As Double) As Double
- FunctionEval1 = Exp(2 / X) * Cos(2 * X)
- End Function
- Function FunctionEval2(ByVal X As Double) As Double
- FunctionEval2 = Cos(3 * X) * Sin(5 * X)
- End Function
- Private Sub Command1_Click()
- Dim t As Double
- Dim XMin As Double, XMax As Double, YMin As Double, YMax As Double
- Dim XPixels As Integer
- YMin = 1E+101
- YMax = -1E+101
- XMin = 2
- XMax = 10
- Picture1.Cls
- Picture1.ScaleMode = 3
- XPixels = Picture1.ScaleWidth - 1
- ' Calculate Min and Max for Y axis
- For i = 1 To XPixels
- t = XMin + (XMax - XMin) * i / XPixels
- functionVal = FunctionEval1(t)
- If functionVal > YMax Then YMax = functionVal
- If functionVal < YMin Then YMin = functionVal
- ' Set up a user defined scale mode
- Picture1.Scale (XMin, YMin)-(XMax, YMax)
- Picture1.ForeColor = RGB(0, 0, 255)
- ' Moce to the first point
- Picture1.PSet (XMin, FunctionEval1(XMin))
- ' Plot the function
- For i = 0 To XPixels
- t = XMin + (XMax - XMin) * i / XPixels
- 'Picture1.PSet (t, FunctionEval2(t))
- Picture1.Line -(t, FunctionEval1(t))
- End Sub
- Private Sub Command2_Click()
- Dim t As Double
- Dim XMin As Double, XMax As Double, YMin As Double, YMax As Double
- Dim XPixels As Integer
- YMin = 1E+101
- YMax = -1E+101
- XMin = 2
- XMax = 10
- Picture1.Cls
- Picture1.ScaleMode = 3
- XPixels = Picture1.ScaleWidth - 1
- ' Calculate Min and Max for Y axis
- For i = 0 To XPixels
- t = XMin + (XMax - XMin) * i / XPixels
- functionVal = Cos(3 * t) * Sin(5 * t)
- If functionVal > YMax Then YMax = functionVal
- If functionVal < YMin Then YMin = functionVal
- ' Set up a user defined scale mode
- Picture1.Scale (XMin, YMin)-(XMax, YMax)
- Picture1.ForeColor = RGB(255, 0, 0)
- ' Plot the function
- For i = 0 To XPixels - 1
- t = XMin + (XMax - XMin) * i / XPixels
- functionVal = Cos(3 * t) * Sin(5 * t)
- 'Picture1.PSet (t, functionVal)
- Picture1.Line -(t, functionVal)
- End Sub
- Private Sub Command3_Click()
- Dim t As Double
- Dim XMin As Double, XMax As Double, YMin As Double, YMax As Double
- Dim XPixels As Integer
- YMin = 1E+101
- YMax = -1E+101
- XMin = 2
- XMax = 10
- Picture1.Cls
- Picture1.ScaleMode = 3
- XPixels = Picture1.ScaleWidth - 1
- ' Calculate Min and Max for Y axis
- For i = 1 To XPixels
- t = XMin + (XMax - XMin) * i / XPixels
- functionVal = FunctionEval1(t)
- If functionVal > YMax Then YMax = functionVal
- If functionVal < YMin Then YMin = functionVal
- ' Set up a user defined scale mode
- Picture1.Scale (XMin, YMin)-(XMax, YMax)
- Picture1.ForeColor = RGB(0, 0, 255)
- ' Moce to the first point
- Picture1.PSet (XMin, FunctionEval1(XMin))
- ' Plot the function
- For i = 0 To XPixels
- t = XMin + (XMax - XMin) * i / XPixels
- 'Picture1.PSet (t, FunctionEval2(t))
- Picture1.Line -(t, FunctionEval1(t))
- Picture1.ForeColor = RGB(255, 0, 0)
- Picture1.PSet (XMin, FunctionEval2(XMin))
- ' Plot the function
- For i = 0 To XPixels
- t = XMin + (XMax - XMin) * i / XPixels
- 'Picture1.PSet (t, FunctionEval2(t))
- Picture1.Line -(t, FunctionEval2(t))
- End Sub
-