Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21843

how to use mschart

$
0
0
hey
i have a form that called expenses
that caulculates the money in spend lets say a tv or a car
now i know there is a funcion in vb called ms chart that shows the grafh
what i want to do is to make a graph with the months of the year
and will show me how much i spend in may , april june and so on
i relly need this to my projecct.
this is the code for the of the form

Code:

Private Sub BttnDelete_Click()
    LsVw.SetFocus
    If MsgBox("?Delete", vbInformation + vbDefaultButton2 + vbYesNo, LsVw.SelectedItem) = vbNo Then Exit Sub
   
    Dim NewIdx As Long
    Set RS = CN.Execute("DELETE * FROM Expenses WHERE ExpID= " & LsVw.SelectedItem.Tag)
    With LsVw
        NewIdx = IIf(.SelectedItem.Index = .ListItems.Count, .ListItems.Count - 1, .SelectedItem.Index)
        .ListItems.Remove .SelectedItem.Index
        If .ListItems.Count > 0 Then Set .SelectedItem = .ListItems(NewIdx)
    End With
End Sub

Private Sub bttnreport_Click()
Set dtrrpt.DataSource = CN.Execute("select * from expenses ")
dtrrpt.show 1
End Sub

Private Sub Form_Load()
 
 
    Me.WindowState = 2
    LsVw.ColumnHeaders(1).Icon = "asc"
    Set RS = CN.Execute("SELECT * FROM Expenses ORDER BY ExpDate")
    While Not RS.EOF
        Set Itm = LsVw.ListItems.Add(, , Format(RS!ExpDate, "dd/mm/yyyy"), , "dolar")
        Itm.Tag = RS!ExpID
        Itm.SubItems(1) = RS!ExpType
        Itm.SubItems(2) = RS!ExpQuantity
        Itm.SubItems(3) = RS!ExpCost
        RS.MoveNext
    Wend
    ListRTL LsVw
        mLVClrHdr.HookToLV LsVw.hwnd, True
    mLVClrHdr.glHdrBkClr = &HD1B499
    mLVClrHdr.glHdrTextClr = vbWhite
    m_hookedLV = True
End Sub

Private Sub BttnBack_Click()
    Unload Me
End Sub

 

Private Sub BttnEdit_Click()
    NewRec = False
    LsVw.SetFocus
    FrmNewExpense.show 1
End Sub

Private Sub BttnNew_Click()
    NewRec = True
    LsVw.SetFocus
    FrmNewExpense.show 1
End Sub

Private Sub LsVw_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
    If ColumnHeader.Index = 1 Then
        LsVw.ListItems.clear
        ColumnHeader.Icon = IIf(ColumnHeader.Icon = "asc", "desc", "asc")
   
        If ColumnHeader.Icon = "asc" Then
            Set RS = CN.Execute("SELECT * FROM Expenses ORDER BY ExpDate")
        Else
            Set RS = CN.Execute("SELECT * FROM Expenses ORDER BY ExpDate DESC")
        End If
   
        LsVw.ListItems.clear
        While Not RS.EOF
            Set Itm = LsVw.ListItems.Add(, , Format(RS!ExpDate, "dd/mm/yyyy"), , "dolar")
            Itm.Tag = RS!ExpID
            Itm.SubItems(1) = RS!ExpType
            Itm.SubItems(2) = RS!ExpQuantity
            Itm.SubItems(3) = RS!ExpCost
            RS.MoveNext
        Wend
    End If
End Sub

Private Sub lvButtons_H5_Click()

End Sub

Private Sub refresh_Click()
LsVw.refresh
End Sub

Private Sub report_Click()

End Sub

Private Sub Tmr_Timer()
 If LsVw.ListItems.Count = 0 Then
        BttnEdit.Enabled = False
        BttnDelete.Enabled = False
        TxtQuantity.text = 0
        TxtCost.text = FormatCurrency(CStr(0), 2) 
        Exit Sub
    Else
        BttnEdit.Enabled = True
        BttnDelete.Enabled = True
    End If
    Set RS = CN.Execute("SELECT SUM(ExpQuantity) as SumQ, SUM(ExpCost) as SumC FROM Expenses")
    If RS.EOF Then
        TxtQuantity.text = 0
        TxtCost.text = CStr(0)
    Else
        TxtQuantity.text = RS!SumQ
        TxtCost.text = CStr(RS!SumC)
    End If
    TxtCost.text = FormatCurrency(TxtCost.text, 2)
 



 
End Sub
Private Sub Form_Resize()
If MDImain.WindowState <> 2 Then Exit Sub
   
    With LsVw
        .Width = Me.Width - 500
        .Height = Me.Height - 1800
        .Left = ((Me.Width - .Width) / 2) - 50
        For I = 1 To 4
            .ColumnHeaders(I).Width = .Width / 4 - 110
        Next
   
        bttnreport.Top = .Top + .Height + 200
        lvButtons_H2.Top = .Top + .Height + 300
        BttnDelete.Top = .Top + .Height + 200
        lvButtons_H3.Top = .Top + .Height + 300
        BttnEdit.Top = .Top + .Height + 200
        lvButtons_H1.Top = .Top + .Height + 300
        BttnNew.Top = .Top + .Height + 200
        lvButtons_H4.Top = .Top + .Height + 300
        Label1.Top = .Top + .Height + 100
        Label2.Top = .Top + .Height + 600
        TxtQuantity.Top = .Top + .Height + 100
        TxtCost.Top = .Top + .Height + 500
        TxtQuantity.Left = .Left + 10
        TxtCost.Left = .Left + 10
        Label1.Left = .Left + 1850
        Label2.Left = .Left + 2100

    End With
    DoEvents
End Sub

im just looking for guidnes and some pointers
tnx for the help

Viewing all articles
Browse latest Browse all 21843

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>