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
Testing numeric TextBox if it is empty....
Moderator: Rathinagiri
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Testing numeric TextBox if it is empty....
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.
But this will not work out if the user enters something and deletes the whole thing again. ![Smile :)](./images/smilies/icon_e_smile.gif)
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
![Smile :)](./images/smilies/icon_e_smile.gif)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: Testing numeric TextBox if it is empty....
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
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
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: Testing numeric TextBox if it is empty....
You could access to textbox content directly via a low level function: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
Code: Select all
cRetValue := GetWindowText ( GetControlHandle (cControl,cWindow))
Regards,
Roberto.
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)