Results 1 to 5 of 5

Thread: maximum and minimum value

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2004
    Posts
    100

    maximum and minimum value

    I want to ask if anyone here have any idea how to get a maximum value and the minimum value of a set of given data. I mean its not from a record set.

    Regarding my prob, I have flexgrid like one I attached here.

    How to get a maximum value and minimum value for every row in the FG.

    Pls help.
    Thank U in advance.
    Attached Images Attached Images  

  2. #2
    Fanatic Member
    Join Date
    Jun 2003
    Location
    Worcester, MA
    Posts
    782
    Well if you load all the values for one row in a flexgrid into an array you could do a loop through them, i can show you how if you want.
    C#.net, VB, C++, Java, VS 2005/2008
    Dont' forget to rate posts that are helpful to you.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2004
    Posts
    100
    Pls...show me how

  4. #4
    Fanatic Member
    Join Date
    Jun 2003
    Location
    Worcester, MA
    Posts
    782
    I know how to loop through and find the largest but not how to make an array, i tried something like :

    VB Code:
    1. Dim strTotal as String
    2. Form_Load()
    3. strTotal(1) = "1"
    4. End Sub

    But that doesnt work.....
    C#.net, VB, C++, Java, VS 2005/2008
    Dont' forget to rate posts that are helpful to you.

  5. #5
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Just Loop through the MSFlexGrid rows and columns - no need for an array. Note the following assumes all columns will be checked for a Min or Max values. Adjust the code to suit your needs.

    VB Code:
    1. Dim lngRow As Long
    2. Dim lngCol As Long
    3.  
    4. Dim lngMax As Long
    5. Dim lngMin As Long
    6.  
    7. With MSFlexGrid
    8.      For lngRow = .FixedRows to .Rows - 1
    9.          lngMax = Val(.TextMatrix(lngRow,.FixedCols)
    10.          lngMin = Val(.TextMatrix(lngRow,.FixedCols)
    11.          For lngCol = .FixedCols to .Cols - 1
    12.              If  lngMin > Val(.TextMatrix(lngRow,.FixedCols) Then
    13.                  lngMin = Val(.TextMatrix(lngRow,.FixedCols)
    14.              End If
    15.  
    16.              If  lngMax < Val(.TextMatrix(lngRow,.FixedCols) Then
    17.                  lngMax = Val(.TextMatrix(lngRow,.FixedCols)
    18.              End If
    19.          Next
    20.          debug.print "Row # ";lngRow;" Min=";lngMin;" Max=";lngMax
    21.      Next
    22. End With

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width