Solved

clearing a grid control

Posted on 1998-09-21
6
224 Views
Last Modified: 2010-04-30
What is the simplest way to clear a grid control of all it's data?

Code please...

Thanks
0
Comment
Question by:dtucker
  • 4
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
khaledc earned 100 total points
ID: 1435962
It is simply doing the following:
If your Grid Control is called Grid1 then all you have to do to clear it is:
Grid1.Clear
0
 

Author Comment

by:dtucker
ID: 1435963
Clear is not an option with the Grid control.
Clear is for listboxes, comboboxes and the clipboard.

0
 
LVL 1

Expert Comment

by:khaledc
ID: 1435964
What are you using? VB4 or VB5 and which Grid you are using ?
For MSGrid, there is definitely a "Clear" Property in VB5.

0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:dtucker
ID: 1435965
I am using VB4-16bit, and it's just the plain old GRID control.
But I was able to get the code I needed from the sample loan app. that comes with VB4.

0
 
LVL 1

Expert Comment

by:khaledc
ID: 1435966
dtucker,
I will send a sample code to clear the grid in VB4, give a bit of time.
Regards
0
 
LVL 1

Expert Comment

by:khaledc
ID: 1435967
OK,
Suppose your Grid is called Grid1 then the code to clear the whole grid is as follows:
First, Get the number of rows and columns in your grid, you can do that as followed:
Dim intNumberOfRow as integer
Dim intNumnberOfCol as integer
dim i as integer
dim j as integer
     intNumberOfRow = grid1.cols    'Note Cols property is different from col property
     intNumberOfCol = grid1.rows    ' Note Rows property is different from row property

Second, clear every box as a time:

    for i = 0 to (intNumberOfCol-1)        'Numbering of rows and cols start from 0 and not 1
        for j = 0 to (intNumberOfRow-1)
             Grid1.row = j         'set which row has the attention
             Grid1.col = i          'set which column has the attention
             Grid1.text = ""
        next j
    next i

I hope this answered you question and that your points did not go to waste.
If you still need help on this matter, give me a yell
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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.
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…

706 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

15 Experts available now in Live!

Get 1:1 Help Now