>Maybe it´s a silly question, but I´m having some trouble to validate a NULL value. I´m taking data from a Excel Worksheet, don´t knowing how large is it. So, I need to break my DO WHILE when the program finds a blank cell. My code is something like this.
>
>
> DO WHILE .T.
> micontrol = .cells(lnfila,2).VALUE
> IF micontrol = .null. then
> EXIT
> ENDIF
> *....
> *Some code that works fine...
> *....
> ENDDO
>
>
>Everything works fine, but I never can reach EXIT, and the other code continue excuting, logically sending me an error. Using the debugger, the value for micontrol is .NULL.
>
>What's wrong??
>
>Thanks in advance!
Adrian,
You would check with isnull().
However you're approaching the whole process from a wrong edge IMHO.
1) On a worksheet a cell might be blank for other reasons other than pointing to the 'end' of data.
2) If the whole sheet is full of data then you might be locked in a do while...enddo loop with this approach.
3) Getting data from excel cell by cell is simply a way to create slow executing code.
If blank cell is your only way then Excel has CurrentRegion.
If you want to know 'used range' on a worksheet then there is UsedRange.
And you can get data from an excel worksheet with a single SQLExec() (or ADO command) and relieve yourself from slow executing:
do while ...
....cells
enddo
My .2 cents.
Cetin