ameens
asked on
DBGrid 1/2 & 1/4
I am writing a program that uses labour times that need to be entered into a grid in 1/2 & 1/4 (Eg.) 1.2 0r 1.6 0r 2.9 etc can somebody please help as i only know how to enter full numbers in the DbGrid
Thanks
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If number of possibilities are too many,
you can just create a Calculated field (without PickList)
then parse the string to make sure it is valid (does not have invalid characters).
then if there is a space, take all numbers before the space to treat them as a whole number (store it in wholeNum var).
then search for "/", if exists take number before and after "/" and
Following is some code you have to apply it to OnCalc event of the Calcuted field you created in first step.
var
wholeNum : Integer;
frac, actual_num : double;
begin
// store value to wholeNum here
frac := numBeforeSlash / numAfterSlash;
actual_num := wholeNum + frac;
// store actual_num to the database
HTH
Ashok
you can just create a Calculated field (without PickList)
then parse the string to make sure it is valid (does not have invalid characters).
then if there is a space, take all numbers before the space to treat them as a whole number (store it in wholeNum var).
then search for "/", if exists take number before and after "/" and
Following is some code you have to apply it to OnCalc event of the Calcuted field you created in first step.
var
wholeNum : Integer;
frac, actual_num : double;
begin
// store value to wholeNum here
frac := numBeforeSlash / numAfterSlash;
actual_num := wholeNum + frac;
// store actual_num to the database
HTH
Ashok
You want to enter float numbers in the DBGrid on runtime? Because ... if it is a DBGrid it should be connected to a Table/Query datasource. And if the table/Query contains records that have on some fields values that are not integer... then the DBGrid will show them without problem. So your question must be about entering the values in editing mode on runtime.
For that you should try to use the '.' separator for decimals. In case that this is your problem, you could make a function on keypressed event (up/down/pressed) that captures the key pressed and replaces it with '.' if it is ','.
Let me know if I understood your question.
If not then elaborate it.
Cheers