Testing numeric TextBox if it is empty....

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

Post Reply
User avatar
mol
Posts: 2640
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 61 times
Been thanked: 23 times
Contact:

Testing numeric TextBox if it is empty....

Post by mol » Sat Oct 11, 2008 9:13 am

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

User avatar
Rathinagiri
Posts: 5039
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 76 times
Been thanked: 89 times
Contact:

Post by Rathinagiri » Sat Oct 11, 2008 12:09 pm

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. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
mol
Posts: 2640
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 61 times
Been thanked: 23 times
Contact:

Post by mol » Mon Oct 13, 2008 8:08 pm

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

User avatar
Roberto Lopez
HMG Founder
Posts: 3873
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 6 times
Been thanked: 99 times

Post by Roberto Lopez » Tue Oct 14, 2008 12:03 am

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.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)


Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest