Dear Experts, I have a MSFlexGrid1 With 5 colums of integer data, max integer is 1 to 50.
I would like to countsort these colums, so that I end up with a list in a second MSFlexgrid2, of the counted and sorted data like the list below. In the second MSFlexgrid2 there should be only two colums as shown below. The code will need to identify the individual numbers from 1 to 50, and show how many times they are repeated in the 5 columns. I am using vb6. Your help would be appreciated, thank you.
Number Frequency
1 80
2 65
3 45
4 90
etc etc
50 120
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
Private Sub Command1_Click() On Error GoTo Err_Handler Dim c As Long Dim r As Long Dim nValue As Long Dim nCountColumns As Long Dim aNumers(1 To 50) As Long nCountColumns = 5 With MSFlexGrid1 nValue = 0 For r = 1 To .Rows - 1 For c = 0 To nCountColumns - 1 If Len(.TextMatrix(r, c)) > 0 Then If IsNumeric(.TextMatrix(r, c)) Then nValue = Val(.TextMatrix(r, c)) If (nValue > 0) And (nValue <= 50) Then aNumers(nValue) = aNumers(nValue) + 1 End If End If End If Next c Next r End With Call FillCountGrid(aNumers(), MSFlexGrid2) Exit SubErr_Handler: Debug.Print "ERROR (Command1_Click): " & CStr(Err.Number) & ", " & Err.DescriptionEnd Sub
Version 2, Worked very well. Thank you, you get maximum points for that answer.
AWaterfalls
ASKER
I've requested that this question be closed as follows:
Accepted answer: 0 points for AWaterfalls's comment #a38731535
for the following reason:
It Just Worked First Tme.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
In her post {http:#a38731535}
Asker said:
"Version 2, Worked very well. Thank you, you get maximum points for that answer."
In her post {http:#a38731585}
Asker accidentally accept his own Answer:
(Version 2, Worked very well. Thank you, you get maximum points for that answer.)
Asker said as Grading Comment:
"It Just Worked First Tme."
eemit
AWaterfalls
ASKER
I am sorry but I am New to all this, however the first solution gave only zeros for the frequency on the second flexgrid. While solution 2 gave the frequencies of the balls as per requested by me. Thank you for your help, and I look forward to using experts again in the future.
Open in new window