Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Check for text in grid

Posted on 2000-04-15
7
Medium Priority
?
190 Views
Last Modified: 2010-05-02
Can you tell me what I am doing wrong.
I am trying to check a grid with only one Row and checking each coloum or(sel) in that row to see if the coloum or(sel) is empty or has text.
This is some of my code.

W = 1
  Grid2.Row = 0
             For T = 0 To NoCols - 1
             Grid2.Col = T
            If Grid2.Text = "" Then
            'If Len(Grid2.Text) = 0 Then
            W = 0
           
            End If
    Next T
0
Comment
Question by:mad3654
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Expert Comment

by:shideyi
ID: 2719041
in your program, as long as there is 1 cell with text = "", W will be set to zero, instead use the following code:

W = 0
Grid2.Row = 0
For T = 0 To NoCols - 1
  Grid2.Col = T
  If Grid2.Text <> "" Then
    W = 1
  End If
Next T

also, if you are using MS flexgrid, the first row will be the columnheader, not the first row containing data.
0
 

Author Comment

by:mad3654
ID: 2719115
Adjusted points from 50 to 75
0
 

Author Comment

by:mad3654
ID: 2719116
I tried this code and it always returns W as 0.  I want to check a grid with one Row and each coloumn or is it sel, of that Row to see if any of the coloumns or sels have no text.  
If ALL coloumns or sels have text then W = 0
Else W = 1.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 6

Accepted Solution

by:
Marine earned 225 total points
ID: 2719154
Try this code. It should work. I didn't test it.
With msFlexGrid
For i = 0 To .Rows - 1
    For j = 0 To .Cols - 1
       If .TextMatrix(i, j) = "" Then
          .TextMatrix(i, j) = "0"
       Else
          .TextMatrix(i, j) = "1"
       End If
    Next
Next
end with
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2719291

Dim RowHasAColEmpty as Boolean
Dim lngRow as Long
Dim lngCol as Long

Dim lngRow = 3 ' Or any other row you want

With MSFlexGrid1
  For lngCol = 0 To .Cols - 1
    If Len(.TextMatrix (lngRow, lngCol)) = 0 _
    Then
      RowHasAColEmpty = True
      Exit For
    End If
  Next lngIndex
End With

If RowHasAColEmpty _
Then
  ' Do Your Processing here
End If
0
 

Author Comment

by:mad3654
ID: 2719313
Marine's code worked with a little modifications. thanks
0
 
LVL 6

Expert Comment

by:Marine
ID: 2719326
happy programming :)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question