Solved

Check for text in grid

Posted on 2000-04-15
7
183 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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 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…

862 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

25 Experts available now in Live!

Get 1:1 Help Now