Solved

Check for text in grid

Posted on 2000-04-15
7
182 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
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 6

Accepted Solution

by:
Marine earned 75 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 Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now