Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I validate .NULL.?
Message
From
13/02/2007 05:26:14
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01194806
Message ID:
01194995
Views:
13
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform