Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,092 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,806 people online right now. Registration is fast and FREE... Join Now!




plotting graghs using vb.net

 
Reply to this topicStart new topic

plotting graghs using vb.net

bimow55
2 Jun, 2008 - 03:01 AM
Post #1

New D.I.C Head
*

Joined: 2 Jun, 2008
Posts: 3

how do i plott a linear gragh using vb.net. what codes do i use or how do i go about my coding.

i am having problems with a project am working on. its a control that will help users to call the current rate between any two currencies. it will show the history of the flutuations in the currencies and also show the grahical representation of the history. the user will also be able to make conversions with it. please check this for me especially with the graphical aspect. I would be glad if you could help me with the coding.

here is my coding.


CODE
Public Class ConversionControl
    Inherits System.Windows.Forms.UserControl
    Public colTextLeft, colTextRight As New Collection
    Public colLabelLeft, colLabelRight As New Collection
    Public Multipliers(30) As Double
    Dim ctrlTextbox, oldTextBox As Control
    Dim ctrlLabel, oldlabel As Control
    Dim mycolor As Color = Color.Black
    Public xMax As Integer = 10
    Public yMax As Integer = 10
    Dim points(100) As Point
    Public Factor As Double, UpperBound As Integer
    Structure History
        Public Dollar As Decimal
        Public Cedi As Decimal
        Public TimeSpan As Decimal
    End Structure
    Const capacity As Integer = 20
    Dim CurrentRow As Integer = 0
    Dim PreviousRow As Integer
    Public CurrencyHistory(capacity) As History
    Public TimeInterval As Decimal
    Dim space As String = Chr(13) & Chr(10)

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'UserControl1 overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents txtUS As System.Windows.Forms.TextBox
    Friend WithEvents txtGH As System.Windows.Forms.TextBox
    Friend WithEvents lblUS As System.Windows.Forms.Label
    Friend WithEvents lblGH As System.Windows.Forms.Label
    Friend WithEvents btnExit As System.Windows.Forms.Button
    Friend WithEvents btnCalculator As System.Windows.Forms.Button
    Friend WithEvents btnAddConversion As System.Windows.Forms.Button
    Friend WithEvents btnConvertRight As System.Windows.Forms.Button
    Friend WithEvents btnConvertLeft As System.Windows.Forms.Button
    Friend WithEvents lblTimeInterval As System.Windows.Forms.Label
    Friend WithEvents txtTimeInterval As System.Windows.Forms.TextBox
    Friend WithEvents lblName As System.Windows.Forms.Label
    Friend WithEvents btnCurrentRate As System.Windows.Forms.Button
    Friend WithEvents btnNewRate As System.Windows.Forms.Button
    Friend WithEvents tbHistory As System.Windows.Forms.TabControl
    Friend WithEvents tbHistoryValue As System.Windows.Forms.TabPage
    Friend WithEvents tbGraphicalHistory As System.Windows.Forms.TabPage
    Friend WithEvents lblUsValue As System.Windows.Forms.Label
    Friend WithEvents lblGhValue As System.Windows.Forms.Label
    Friend WithEvents lblTimeSpan As System.Windows.Forms.Label
    Friend WithEvents lstUsValue As System.Windows.Forms.ListBox
    Friend WithEvents lstGhValue As System.Windows.Forms.ListBox
    Friend WithEvents lstTimeSpan As System.Windows.Forms.ListBox
    Friend WithEvents btnClearHistory As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.tbHistory = New System.Windows.Forms.TabControl
        Me.tbHistoryValue = New System.Windows.Forms.TabPage
        Me.lstTimeSpan = New System.Windows.Forms.ListBox
        Me.lstGhValue = New System.Windows.Forms.ListBox
        Me.lstUsValue = New System.Windows.Forms.ListBox
        Me.lblTimeSpan = New System.Windows.Forms.Label
        Me.lblGhValue = New System.Windows.Forms.Label
        Me.lblUsValue = New System.Windows.Forms.Label
        Me.lblTimeInterval = New System.Windows.Forms.Label
        Me.txtTimeInterval = New System.Windows.Forms.TextBox
        Me.tbGraphicalHistory = New System.Windows.Forms.TabPage
        Me.txtUS = New System.Windows.Forms.TextBox
        Me.txtGH = New System.Windows.Forms.TextBox
        Me.lblUS = New System.Windows.Forms.Label
        Me.lblGH = New System.Windows.Forms.Label
        Me.btnExit = New System.Windows.Forms.Button
        Me.btnCalculator = New System.Windows.Forms.Button
        Me.btnAddConversion = New System.Windows.Forms.Button
        Me.btnConvertRight = New System.Windows.Forms.Button
        Me.btnConvertLeft = New System.Windows.Forms.Button
        Me.lblName = New System.Windows.Forms.Label
        Me.btnCurrentRate = New System.Windows.Forms.Button
        Me.btnNewRate = New System.Windows.Forms.Button
        Me.btnClearHistory = New System.Windows.Forms.Button
        Me.tbHistory.SuspendLayout()
        Me.tbHistoryValue.SuspendLayout()
        Me.SuspendLayout()
        '
        'tbHistory
        '
        Me.tbHistory.Controls.Add(Me.tbHistoryValue)
        Me.tbHistory.Controls.Add(Me.tbGraphicalHistory)
        Me.tbHistory.Location = New System.Drawing.Point(40, 272)
        Me.tbHistory.Name = "tbHistory"
        Me.tbHistory.SelectedIndex = 0
        Me.tbHistory.Size = New System.Drawing.Size(608, 336)
        Me.tbHistory.TabIndex = 38
        '
        'tbHistoryValue
        '
        Me.tbHistoryValue.BackColor = System.Drawing.Color.RosyBrown
        Me.tbHistoryValue.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.tbHistoryValue.Controls.Add(Me.btnClearHistory)
        Me.tbHistoryValue.Controls.Add(Me.lstTimeSpan)
        Me.tbHistoryValue.Controls.Add(Me.lstGhValue)
        Me.tbHistoryValue.Controls.Add(Me.lstUsValue)
        Me.tbHistoryValue.Controls.Add(Me.lblTimeSpan)
        Me.tbHistoryValue.Controls.Add(Me.lblGhValue)
        Me.tbHistoryValue.Controls.Add(Me.lblUsValue)
        Me.tbHistoryValue.Controls.Add(Me.lblTimeInterval)
        Me.tbHistoryValue.Controls.Add(Me.txtTimeInterval)
        Me.tbHistoryValue.ForeColor = System.Drawing.SystemColors.ControlText
        Me.tbHistoryValue.Location = New System.Drawing.Point(4, 22)
        Me.tbHistoryValue.Name = "tbHistoryValue"
        Me.tbHistoryValue.Size = New System.Drawing.Size(600, 310)
        Me.tbHistoryValue.TabIndex = 0
        Me.tbHistoryValue.Text = "History Values"
        '
        'lstTimeSpan
        '
        Me.lstTimeSpan.Location = New System.Drawing.Point(272, 40)
        Me.lstTimeSpan.Name = "lstTimeSpan"
        Me.lstTimeSpan.RightToLeft = System.Windows.Forms.RightToLeft.Yes
        Me.lstTimeSpan.Size = New System.Drawing.Size(64, 238)
        Me.lstTimeSpan.TabIndex = 11
        '
        'lstGhValue
        '
        Me.lstGhValue.Location = New System.Drawing.Point(148, 40)
        Me.lstGhValue.Name = "lstGhValue"
        Me.lstGhValue.RightToLeft = System.Windows.Forms.RightToLeft.Yes
        Me.lstGhValue.Size = New System.Drawing.Size(64, 238)
        Me.lstGhValue.TabIndex = 10
        '
        'lstUsValue
        '
        Me.lstUsValue.Location = New System.Drawing.Point(24, 40)
        Me.lstUsValue.Name = "lstUsValue"
        Me.lstUsValue.RightToLeft = System.Windows.Forms.RightToLeft.Yes
        Me.lstUsValue.Size = New System.Drawing.Size(64, 238)
        Me.lstUsValue.TabIndex = 9
        '
        'lblTimeSpan
        '
        Me.lblTimeSpan.Location = New System.Drawing.Point(248, 16)
        Me.lblTimeSpan.Name = "lblTimeSpan"
        Me.lblTimeSpan.Size = New System.Drawing.Size(120, 23)
        Me.lblTimeSpan.TabIndex = 8
        Me.lblTimeSpan.Text = "Time Span (in months)"
        '
        'lblGhValue
        '
        Me.lblGhValue.Location = New System.Drawing.Point(136, 16)
        Me.lblGhValue.Name = "lblGhValue"
        Me.lblGhValue.TabIndex = 7
        Me.lblGhValue.Text = "GH¢ Value"
        '
        'lblUsValue
        '
        Me.lblUsValue.Location = New System.Drawing.Point(24, 16)
        Me.lblUsValue.Name = "lblUsValue"
        Me.lblUsValue.TabIndex = 6
        Me.lblUsValue.Text = "US$ Value"
        '
        'lblTimeInterval
        '
        Me.lblTimeInterval.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblTimeInterval.Location = New System.Drawing.Point(368, 232)
        Me.lblTimeInterval.Name = "lblTimeInterval"
        Me.lblTimeInterval.TabIndex = 5
        Me.lblTimeInterval.Text = "Time Interval"
        '
        'txtTimeInterval
        '
        Me.txtTimeInterval.Location = New System.Drawing.Point(360, 256)
        Me.txtTimeInterval.Name = "txtTimeInterval"
        Me.txtTimeInterval.RightToLeft = System.Windows.Forms.RightToLeft.Yes
        Me.txtTimeInterval.TabIndex = 2
        Me.txtTimeInterval.Text = ""
        '
        'tbGraphicalHistory
        '
        Me.tbGraphicalHistory.BackColor = System.Drawing.Color.White
        Me.tbGraphicalHistory.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.tbGraphicalHistory.Location = New System.Drawing.Point(4, 22)
        Me.tbGraphicalHistory.Name = "tbGraphicalHistory"
        Me.tbGraphicalHistory.Size = New System.Drawing.Size(600, 310)
        Me.tbGraphicalHistory.TabIndex = 1
        Me.tbGraphicalHistory.Text = "View Graphical History"
        Me.tbGraphicalHistory.Visible = False
        '
        'txtUS
        '
        Me.txtUS.Location = New System.Drawing.Point(296, 104)
        Me.txtUS.Name = "txtUS"
        Me.txtUS.RightToLeft = System.Windows.Forms.RightToLeft.Yes
        Me.txtUS.TabIndex = 37
        Me.txtUS.Text = ""
        '
        'txtGH
        '
        Me.txtGH.Location = New System.Drawing.Point(88, 104)
        Me.txtGH.Name = "txtGH"
        Me.txtGH.RightToLeft = System.Windows.Forms.RightToLeft.Yes
        Me.txtGH.TabIndex = 36
        Me.txtGH.Text = ""
        '
        'lblUS
        '
        Me.lblUS.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblUS.Location = New System.Drawing.Point(248, 104)
        Me.lblUS.Name = "lblUS"
        Me.lblUS.Size = New System.Drawing.Size(40, 23)
        Me.lblUS.TabIndex = 35
        Me.lblUS.Text = "US$"
        '
        'lblGH
        '
        Me.lblGH.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblGH.Location = New System.Drawing.Point(32, 104)
        Me.lblGH.Name = "lblGH"
        Me.lblGH.Size = New System.Drawing.Size(40, 23)
        Me.lblGH.TabIndex = 34
        Me.lblGH.Text = "GH¢"
        '
        'btnExit
        '
        Me.btnExit.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(192, Byte), CType(128, Byte))
        Me.btnExit.Location = New System.Drawing.Point(448, 224)
        Me.btnExit.Name = "btnExit"
        Me.btnExit.Size = New System.Drawing.Size(144, 40)
        Me.btnExit.TabIndex = 33
        Me.btnExit.Text = "Close"
        '
        'btnCalculator
        '
        Me.btnCalculator.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(192, Byte), CType(128, Byte))
        Me.btnCalculator.Location = New System.Drawing.Point(448, 184)
        Me.btnCalculator.Name = "btnCalculator"
        Me.btnCalculator.Size = New System.Drawing.Size(144, 40)
        Me.btnCalculator.TabIndex = 32
        Me.btnCalculator.Text = "Calculator"
        '
        'btnAddConversion
        '
        Me.btnAddConversion.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(192, Byte), CType(128, Byte))
        Me.btnAddConversion.Location = New System.Drawing.Point(448, 144)
        Me.btnAddConversion.Name = "btnAddConversion"
        Me.btnAddConversion.Size = New System.Drawing.Size(144, 40)
        Me.btnAddConversion.TabIndex = 31
        Me.btnAddConversion.Text = "Add Conversion"
        '
        'btnConvertRight
        '
        Me.btnConvertRight.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(192, Byte), CType(128, Byte))
        Me.btnConvertRight.Location = New System.Drawing.Point(288, 56)
        Me.btnConvertRight.Name = "btnConvertRight"
        Me.btnConvertRight.Size = New System.Drawing.Size(120, 40)
        Me.btnConvertRight.TabIndex = 30
        Me.btnConvertRight.Text = "Convert Right"
        '
        'btnConvertLeft
        '
        Me.btnConvertLeft.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(192, Byte), CType(128, Byte))
        Me.btnConvertLeft.Location = New System.Drawing.Point(80, 56)
        Me.btnConvertLeft.Name = "btnConvertLeft"
        Me.btnConvertLeft.Size = New System.Drawing.Size(120, 40)
        Me.btnConvertLeft.TabIndex = 29
        Me.btnConvertLeft.Text = "Convert Left"
        '
        'lblName
        '
        Me.lblName.Font = New System.Drawing.Font("Monotype Corsiva", 14.25!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblName.ForeColor = System.Drawing.Color.DarkGoldenrod
        Me.lblName.Location = New System.Drawing.Point(128, 16)
        Me.lblName.Name = "lblName"
        Me.lblName.Size = New System.Drawing.Size(392, 23)
        Me.lblName.TabIndex = 39
        Me.lblName.Text = "Currency Convertor for Ghana Cedis to US Dollars"
        '
        'btnCurrentRate
        '
        Me.btnCurrentRate.BackColor = System.Drawing.Color.DarkSeaGreen
        Me.btnCurrentRate.Location = New System.Drawing.Point(448, 56)
        Me.btnCurrentRate.Name = "btnCurrentRate"
        Me.btnCurrentRate.Size = New System.Drawing.Size(144, 40)
        Me.btnCurrentRate.TabIndex = 40
        Me.btnCurrentRate.Text = "Current Rate"
        '
        'btnNewRate
        '
        Me.btnNewRate.BackColor = System.Drawing.Color.DarkSeaGreen
        Me.btnNewRate.Location = New System.Drawing.Point(448, 96)
        Me.btnNewRate.Name = "btnNewRate"
        Me.btnNewRate.Size = New System.Drawing.Size(144, 40)
        Me.btnNewRate.TabIndex = 41
        Me.btnNewRate.Text = "New Rate"
        '
        'btnClearHistory
        '
        Me.btnClearHistory.BackColor = System.Drawing.Color.OrangeRed
        Me.btnClearHistory.Location = New System.Drawing.Point(488, 256)
        Me.btnClearHistory.Name = "btnClearHistory"
        Me.btnClearHistory.Size = New System.Drawing.Size(80, 23)
        Me.btnClearHistory.TabIndex = 12
        Me.btnClearHistory.Text = "Clear History"
        '
        'ConversionControl
        '
        Me.BackColor = System.Drawing.Color.DarkSeaGreen
        Me.Controls.Add(Me.btnNewRate)
        Me.Controls.Add(Me.btnCurrentRate)
        Me.Controls.Add(Me.lblName)
        Me.Controls.Add(Me.tbHistory)
        Me.Controls.Add(Me.txtUS)
        Me.Controls.Add(Me.txtGH)
        Me.Controls.Add(Me.lblUS)
        Me.Controls.Add(Me.lblGH)
        Me.Controls.Add(Me.btnExit)
        Me.Controls.Add(Me.btnCalculator)
        Me.Controls.Add(Me.btnAddConversion)
        Me.Controls.Add(Me.btnConvertRight)
        Me.Controls.Add(Me.btnConvertLeft)
        Me.Location = New System.Drawing.Point(90, 10)
        Me.Name = "ConversionControl"
        Me.Size = New System.Drawing.Size(688, 632)
        Me.tbHistory.ResumeLayout(False)
        Me.tbHistoryValue.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub UserControl1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        colTextLeft.Add(txtGH)
        colTextRight.Add(txtUS)
        colLabelLeft.Add(lblGH)
        colLabelRight.Add(lblUS)
        Multipliers(1) = CurrencyHistory(CurrentRow).cedi
        txtTimeInterval.Text = TimeInterval
        If CurrentRow = capacity Then
            MessageBox.Show("Table for History values full" & space & "Clear History")
            Exit Sub
        End If
    End Sub

    Private Sub btnConvertLeft_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConvertLeft.Click
        Dim x As Integer, result As Double
        Dim ctrlLText, ctrlRText As Control
        x = 1
        For Each ctrlLText In colTextLeft
            If Len(ctrlLText.Text) <> 0 Then
                result = CDbl(ctrlLText.Text) * Multipliers(x)
                ctrlRText = colTextRight.Item(x)
                If result < 0.00001 Then
                    ctrlRText.Text = Format(result, "0.0###e-##")
                Else
                    ctrlRText.Text = Format(result, "#,##0.###")
                End If
            End If
            x += 1
        Next
    End Sub

    Private Sub btnConvertRight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConvertRight.Click
        Dim x As Integer, result As Double
        Dim ctrlRText, ctrlLText As Control
        x = 1
        For Each ctrlRText In colTextRight
            If Len(ctrlRText.Text) <> 0 Then
                result = CDbl(ctrlRText.Text) / Multipliers(x)
                ctrlLText = colTextLeft.Item(x)
                If result < 0.00001 Then
                    ctrlLText.Text = Format(result, "0.0###e-##")
                Else
                    ctrlLText.Text = Format(result, "#,##0.###")
                End If
            End If
            x += 1
        Next
    End Sub

    Private Sub btnCalculator_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculator.Click
        Dim value As Long
        Try
            value = Shell("c:\windows\system32\calc.exe", Microsoft.VisualBasic.AppWinStyle.NormalNoFocus)
        Catch
            MessageBox.Show("Cannot find application")
        End Try
    End Sub
    Sub initializetextbox()
        Dim LocVar As Point
        Me.Controls.Add(ctrlTextbox)
        LocVar.Y = oldTextBox.Location.Y + 25
        LocVar.X = oldTextBox.Location.X
        With ctrlTextbox
            .Location = LocVar
            .Text = ""
            .Show()
            .Focus()
        End With
    End Sub
    Sub iniitializelabel(ByVal unittext As String)
        Dim LocVar As Point
        'add control to the form's controls collection
        Me.Controls.Add(ctrlLabel)
        'set the location of the new control
        LocVar.Y = oldlabel.Location.Y + 25
        LocVar.X = oldlabel.Location.X
        With ctrlLabel
            .Location = LocVar
            .Text = unittext
            .Show()
        End With
    End Sub

    Private Sub btnAddConversion_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddConversion.Click
        Dim LeftUnit, RightUnit As String

        'The Left Text Box's unit of measure
        LeftUnit = InputBox("enter the left unit:")
        'if no entry, then bailOut
        If Len(LeftUnit) = 0 Then GoTo BailOut
        RightUnit = InputBox("enter the right Unit:")
        If Len(RightUnit) = 0 Then GoTo BailOut
        UpperBound = colTextLeft.Count + 1
        'set oldtextbox equal to the last textbox in the column
        oldTextBox = colTextLeft.Item(UpperBound - 1)
        'user enters the multiplier for the conversion
        Multipliers(UpperBound) = CDbl(InputBox("enter the multiplier:"))
        'creat new textbox
        ctrlTextbox = New TextBox
        colTextLeft.Add(ctrlTextbox)
        'set some of the text box's properties
        initializetextbox()
        'repeat for right text box
        oldTextBox = colTextRight.Item(UpperBound - 1)
        ctrlTextbox = New TextBox
        colTextRight.Add(ctrlTextbox)
        initializetextbox()
        'set oldlabel to the previously defined left label
        oldlabel = colLabelLeft.Item(UpperBound - 1)
        'creat the new left label
        ctrlLabel = New Label
        colLabelLeft.Add(ctrlLabel)
        iniitializelabel(LeftUnit)
        'set oldlabel to the previously defined right label
        oldlabel = colLabelRight.Item(UpperBound - 1)
        'creat the new left label
        ctrlLabel = New Label
        colLabelRight.Add(ctrlLabel)
        iniitializelabel(RightUnit)
        Exit Sub
BailOut:
        MessageBox.Show("Try Again Later ....", "Bailing Out")
    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Application.Exit()
    End Sub

    Private Sub tbGraphicalHistory_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles tbGraphicalHistory.Paint
        Dim myPenDraw As New Pen(Color.Red, 2)
        Dim myPrnAxis As New Pen(Color.Green, 2)
        Dim halfx As Integer = tbGraphicalHistory.Size.Width / 12
        Dim halfy As Integer = tbGraphicalHistory.Size.Height / 1.2
        e.Graphics.DrawLine(myPrnAxis, 0, halfy, 13 * halfx, halfy)
        e.Graphics.DrawLine(myPrnAxis, halfx, 0, halfx, 2 * halfy)

        Dim xWidth As Integer = tbGraphicalHistory.Size.Width
        Dim yHeight As Integer = tbGraphicalHistory.Size.Height
        'Dim xMultiple As Double = xWidth / (2 * xMax)
        'Dim yMultiple As Double = -yHeight / (2 * yMax)
        Dim xOffset As Integer = xWidth \ 2
        Dim yOffset As Integer = yHeight \ 2
        Dim x, y As Decimal
        Dim index As Integer = 0

        'cc = CDbl(txtFlutuationValue.Text)
        'dd = CDbl(txtTimeSpan.Text)
        'ee = CDbl(txtTimeInterval.Text)

        For x = -TimeInterval To +TimeInterval Step 1
            y = x * 10
            With points(index)
                .X = CInt(CurrencyHistory(index).TimeSpan) + xOffset
                .Y = CInt(CurrencyHistory(index).Cedi) + yOffset
            End With
            index += 1
        Next
        e.Graphics.DrawLines(myPenDraw, points)
    End Sub

    Private Sub btnCurrentRate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCurrentRate.Click
        If CurrencyHistory(CurrentRow).Dollar <> 0 And CurrencyHistory(CurrentRow).Cedi <> 0 Then
            MessageBox.Show("US$ " & CurrencyHistory(CurrentRow).Dollar.ToString & " = GH¢ " & CurrencyHistory(CurrentRow).Cedi.ToString)
        Else
            MessageBox.Show("No valid entry made")
            Exit Sub
        End If
    End Sub

    Private Sub btnNewRate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewRate.Click
        Dim NewRow As Integer
        NewRow = CurrentRow + 1
        If NewRow > capacity Then
            MessageBox.Show("Table for History values full" & space & "Clear History")
            Exit Sub
        End If
        CurrencyHistory(NewRow).Dollar = CDec(InputBox("Enter the Dollar value"))
        CurrencyHistory(NewRow).Cedi = CDec(InputBox("Enter the Cedi value"))
        lstUsValue.Items.Add(CurrencyHistory(NewRow).Dollar.ToString)
        lstGhValue.Items.Add(CurrencyHistory(NewRow).Cedi.ToString)
        If CurrentRow <> 0 Then
            CurrencyHistory(CurrentRow).TimeSpan = CDec(InputBox("Enter the Time span of Old Rate"))
            lstTimeSpan.Items.Add(CurrencyHistory(CurrentRow).TimeSpan.ToString)
        End If
        CurrentRow = CurrentRow + 1
        PreviousRow = CurrentRow - 1
        TimeInterval = CDec(TimeInterval + CurrencyHistory(PreviousRow).TimeSpan)
        txtTimeInterval.Text = TimeInterval
    End Sub

    Private Sub btnClearHistory_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClearHistory.Click
        Dim count As Integer
        Dim Deduction As Decimal
        If CurrentRow <> 20 Then
            MessageBox.Show("Table for History Values not full")
        Else
            For count = 1 To 20
                With CurrencyHistory(count)
                    .Cedi = 0
                    .Dollar = 0
                    .TimeSpan = 0
                End With
                lstUsValue.Items.Clear()
                lstGhValue.Items.Clear()
                lstTimeSpan.Items.Clear()
            Next
            txtTimeInterval.Clear()
            CurrentRow = 0
        End If
        btnNewRate.Focus()
    End Sub
End Class


User is offlineProfile CardPM
+Quote Post

born2c0de
RE: Plotting Graghs Using Vb.net
3 Jun, 2008 - 02:00 AM
Post #2

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 4,032



Thanked: 38 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
You don't need to write your own graph plotter code.
Don't reinvent the wheel.
Microsoft already ships a control with Windows.

Add a COM Reference to Microsoft Chart Control.
If you can't find it, manually add the MSCHRT20.ocx file.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 12:06AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month