HOW TO COUNT DATA in MSFlexgrid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • uprakash14
    New Member
    • Mar 2007
    • 12

    HOW TO COUNT DATA in MSFlexgrid

    i have import excel data in MSflexgrid.. Now i want to count the data for particulars fields...

    Like Data have four column A, B, C and D
    while using A column, i have to calculate the data of B column..
    plz give me .. code for this...

    Thanx
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Originally posted by uprakash14
    i have import excel data in MSflexgrid.. Now i want to count the data for particulars fields...

    Like Data have four column A, B, C and D
    while using A column, i have to calculate the data of B column..
    plz give me .. code for this...

    Thanx
    Hello uprakash14!

    You've come to the right place, you'll have to tell us a little more. Do you have anything working this very minute. You can help avoid confusion if your code is posted, especially in the event one needs to post a tutorial to help you figure this all out.

    Please stay tuned and good luck.

    Comment

    • uprakash14
      New Member
      • Mar 2007
      • 12

      #3
      Originally posted by Dököll
      Hello uprakash14!

      You've come to the right place, you'll have to tell us a little more. Do you have anything working this very minute. You can help avoid confusion if your code is posted, especially in the event one needs to post a tutorial to help you figure this all out.

      Please stay tuned and good luck.

      i am doing work with excel .. i have imported excel file in MSflexgrid... Now i have prob is that i have to count the records. or we can say that .. count the cells of that excel file. using diff colunm taking into consideration.. .

      thanx

      Comment

      • Dököll
        Recognized Expert Top Contributor
        • Nov 2006
        • 2379

        #4
        Originally posted by uprakash14
        i am doing work with excel .. i have imported excel file in MSflexgrid... Now i have prob is that i have to count the records. or we can say that .. count the cells of that excel file. using diff colunm taking into consideration.. .

        thanx
        Splendid, this means you have a working code. Mind posting it!

        You will get better, sound results that way...

        Comment

        • cmrhema
          Contributor
          • Jan 2007
          • 375

          #5
          Originally posted by uprakash14
          i am doing work with excel .. i have imported excel file in MSflexgrid... Now i have prob is that i have to count the records. or we can say that .. count the cells of that excel file. using diff colunm taking into consideration.. .

          thanx
          This is not my code but try it out(or you can modify)
          =======
          Here is a function that accepts a grid control and a column number. It then
          totals all the rows of the column and returns the total in the name of the
          function. You can probably use or modify this code to do what you need:


          Public Function getGridColumnTo tal(myGrid As Control, myColumn As Long) As
          Single


          'Calculate and return the total of all the cells in a grid's column.
          'The grid to use is passed into the function as myGrid.
          'The column to use is passed into the funcion as myColumn.


          Dim counter As Integer, myTotal As Single, myCell As Single


          'turn on an error handler
          On Error GoTo getGridColumnTo talError


          'set the grid's column to the argument passed into the function
          myGrid.Col = myColumn


          'loop through all the items in the grid
          For counter = 0 To myGrid.Rows - 1
          'set the grid's row to the counter
          myGrid.Row = counter
          'if the text in the current cell is numeric
          If IsNumeric(myGri d.Text) Then
          'retrieve the current cell (pointed to by the grid's Row and Col
          properties
          myCell = myGrid.Text
          'add the cell's contents to a running total
          myTotal = myTotal + myCell
          End If
          Next counter
          'return the grid column's total in the name of the function
          getGridColumnTo tal = myTotal


          'exit to keep from falling into the error handler
          Exit Function
          getGridColumnTo talError:
          'use a message box to indicate an error number and error description
          MsgBox Err & Error, vbCritical, "getGridColumnT otal Error"


          End Function

          Comment

          Working...