    Wrox Programmer Forums FLEXGRID...HELP!!!
 | Search | Today's Posts | Mark Forums Read
 VB How-To Ask your "How do I do this with VB?" questions in this forum.
 Welcome to the p2p.wrox.com Forums. You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 apek Authorized User Join Date: Jan 2004 Location: , , . Posts: 33 Thanks: 0 Thanked 0 Times in 0 Posts FLEXGRID...HELP!!!

i have a flexgrid...
lets say i have 3 columns..and 3 rows..
there are items such as letter G and L in each cell of the grid...
i want my system to analyze every rows..
the analyze here means:

if theres a G/L(or more) on a row,the system will count the G/L that as
1.
its the same for the second row,if theres a G/L(or more),the system
will
increase the count to 2...
and so on....

even if the row has more than one G/L
it count it as one

and the result of this count will be displayed...

from my flexgrid tht i enclosed here, i want the result to be like this :
L = 1, G = 2

my problem is how to the calculation of the G/L in the flexgrid???
i'm really new in VB and i really wanna use flexgrid...

i enclose my code here (that is not work)
Code:
```visual basic code:
For X = 0 To MSFlexGrid1.Rows - 1
For K = 0 To MSFlexGrid1.Cols - 1
'        If MSFlexGrid1.TextMatrix(X, K) = "L" Then
'            l = l + 1
'        ElseIf MSFlexGrid1.TextMatrix(X, K) = "G" Then
'            m = m + 1
'        End If
For i = 0 To i = 1
If MSFlexGrid1.TextMatrix(X, K) = "L" Then
i = i + 1
End
For j = 0 To j = 1
If MSFlexGrid1.TextMatrix(X, K) = "G" Then
j = j + 1
End If
Next
Next
Next```
gbianchi Friend of Wrox
 Points: 7,395, Level: 36   Activity: 0%   Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts hi there..

the second part of your code is horrible.. how can you try to loop the same variables that you are adding???

anyway.. the commented part is okay.. just add the next..

For X = 0 To MSFlexGrid1.Rows - 1
bL = false
bG = false
For K = 0 To MSFlexGrid1.Cols - 1
If MSFlexGrid1.TextMatrix(X, K) = "L" Then
if not bL then
l = l + 1
bL = True
end if
ElseIf MSFlexGrid1.TextMatrix(X, K) = "G" Then
if not bG then
m = m + 1
bG = True
end if
End If
next
next

Gonzalo Bianchi
 apek Authorized User Join Date: Jan 2004 Location: , , . Posts: 33 Thanks: 0 Thanked 0 Times in 0 Posts so do u mean i have to use back the commented part+your code like this?

Code:
```        If MSFlexGrid1.TextMatrix(X, K) = "L" Then
l = l + 1
ElseIf MSFlexGrid1.TextMatrix(X, K) = "G" Then
m = m + 1
End If

For X = 0 To MSFlexGrid1.Rows - 1
bL = false
bG = false
For K = 0 To MSFlexGrid1.Cols - 1
If MSFlexGrid1.TextMatrix(X, K) = "L" Then
if not bL then
l = l + 1
bL = True
end if
ElseIf MSFlexGrid1.TextMatrix(X, K) = "G" Then
if not bG then
m = m + 1
bG = True
end if
End If
next
next```
gbianchi Friend of Wrox
 Points: 7,395, Level: 36   Activity: 0%   Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts just my code will do the trick...

Gonzalo Bianchi
 marcostraf Friend of Wrox Join Date: Jun 2003 Location: Alameda, ca, USA. Posts: 627 Thanks: 0 Thanked 0 Times in 0 Posts If I understood correctly, you want to count how many rows contain at least one letter G and how many a letter L.
This is what I would do:

dim Lcount as long
dim GCount as long

with flexgrid
for k = 0 to .rows-1
for j = 0 to .cols -1
if .textmatrix(k,j) = "L" then
lCount =lCount+1
exit for
endif
next
for j = 0 to .cols -1
if .textmatrix(k,j) = "G" then
GCount =GCount+1
exit for
endif
next
next

The two loops avoid the use of boolean flags, make the code a little more readable and it will be eaiser to update.
Marco Similar Threads Thread Thread Starter Forum Replies Last Post FlexGrid amlesh Beginning VB 6 0 July 26th, 2007 01:31 AM Vs-flexgrid MathLearner Beginning VB 6 0 June 4th, 2007 01:52 AM Flexgrid umeshtheone Beginning VB 6 1 May 30th, 2007 06:02 AM Sendmessage in flexgrid areejan2000 Crystal Reports 0 November 12th, 2005 02:18 AM AllowDrop in FlexGrid agarwalmk C# 0 September 15th, 2003 09:20 AM 