Solved

Check for text in grid

Posted on 2000-04-15
7
189 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

628 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