Page 1 of 1

Testing numeric TextBox if it is empty....

Posted: Sat Oct 11, 2008 9:13 am
by mol
Hello everybody!

I need to test TextBox defined as numeric if it is empty - "on the screen", but not equal to zero.
I need to differ two situations
1) equal to zero - someone inputed 0
2) empty - nothing was already inputed

Have you any suggestions?

Marek

Re: Testing numeric TextBox if it is empty....

Posted: Sat Oct 11, 2008 12:09 pm
by Rathinagiri
One way is this. You don't put any value while defining the control. You have a variable to record whether there is any change in the value of the control. If there is no change, we can be sure that the value is Nil, if it is changed, the value may be 0. Consider my example.

Code: Select all

# include "minigui.ch"

function main
private lValueChanged := .f.

define window sample at 0,0 width 200 height 200 main
define textbox t1
   row 10
   col 10
   width 100
   numeric .t.
   rightalign .t.
   on change lValuechanged := .t.
end textbox
define textbox t2
   row 40
   col 10
   width 100
   numeric .t.
   rightalign .t.
end textbox
define button b1
   row 70
   col 10
   caption "Click Me"
   action msginfo(iif(lValueChanged, str(sample.t1.value),"Entered Nil"))
end button 
end window
sample.center
sample.activate
return nil
But this will not work out if the user enters something and deletes the whole thing again. :)

Re: Testing numeric TextBox if it is empty....

Posted: Mon Oct 13, 2008 8:08 pm
by mol
I rather thought about samothing like in VBA for Excel
In Excel, If I define numeric box e.g. T_Price
T_Price.Value returns it's real value
T_Price.Text returns "buffer", that contains really entered characters

Maybe something undocumented????

Regards, Marek

Re: Testing numeric TextBox if it is empty....

Posted: Tue Oct 14, 2008 12:03 am
by Roberto Lopez
mol wrote:I rather thought about samothing like in VBA for Excel
In Excel, If I define numeric box e.g. T_Price
T_Price.Value returns it's real value
T_Price.Text returns "buffer", that contains really entered characters

Maybe something undocumented????

Regards, Marek
You could access to textbox content directly via a low level function:

Code: Select all

cRetValue := GetWindowText ( GetControlHandle (cControl,cWindow))
Be carefull, since you will be 'bypassing' most of MiniGUI layer, so, it is a non recommended action and coul bring some conflicts.

Regards,

Roberto.

Re: Testing numeric TextBox if it is empty....

Posted: Tue Oct 14, 2008 12:56 pm
by mol
Thanks Roberto,
Marek