Total amount in Data grid Columns

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Serenityquinn15
    New Member
    • Oct 2007
    • 30

    #1

    Total amount in Data grid Columns

    Hi!
    I have little trouble in my Program. I need to total all the amount in specific column.. comes from the data produced by the datagrid..

    heres my code:

    Set rs11 = New Recordset
    rs11.CursorLoca tion = adUseClient
    rs11.Open "Select * From Leave WHERE EmpNo= '" & Txtempno.Text & "'", con, adOpenDynamic, adLockOptimisti c
    Set DataGrid1.DataS ource = rs11

    Dim i
    Dim Total As Double

    For i = 0 To DataGrid1.Appro xCount - 1
    Total =Total + DataGrid1.Colum ns(15).CellValu e(DataGrid1.Get Bookmark(i))
    Next
    TXtTotal.Text =Total

    my problem is the total amount. example:

    Column1

    525.25
    625.50

    Total: 1150.75(which is correct) but it only display like this

    Total : 1150 (without a decimal places)

    How I can fix this??? Please help me.. tnx..
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    Originally posted by Serenityquinn15
    Hi!
    I have little trouble in my Program. I need to total all the amount in specific column.. comes from the data produced by the datagrid..

    heres my code:

    Set rs11 = New Recordset
    rs11.CursorLoca tion = adUseClient
    rs11.Open "Select * From Leave WHERE EmpNo= '" & Txtempno.Text & "'", con, adOpenDynamic, adLockOptimisti c
    Set DataGrid1.DataS ource = rs11

    Dim i
    Dim Total As Double

    For i = 0 To DataGrid1.Appro xCount - 1
    Total =Total + DataGrid1.Colum ns(15).CellValu e(DataGrid1.Get Bookmark(i))
    Next
    TXtTotal.Text =Total

    my problem is the total amount. example:

    Column1

    525.25
    625.50

    Total: 1150.75(which is correct) but it only display like this

    Total : 1150 (without a decimal places)

    How I can fix this??? Please help me.. tnx..

    Do you want the decimal points or you do NOT want them?

    Here is a thread on rounding in VB

    Comment

    • Serenityquinn15
      New Member
      • Oct 2007
      • 30

      #3
      Originally posted by jeffstl
      Do you want the decimal points or you do NOT want them?

      Here is a thread on rounding in VB

      http://www.thescripts.com/forum/thread546299.html
      I need a number with decimal places....

      Comment

      Working...