which fieldtype to choose when storing a floating point value

hi folks,
i have a paradox table with some numerical values. in my app there is a calculation which often has a result like 4,75. which type of field (BCD, numerical, date/time ....)do i have to choose for this field in the database. later on i will use this floating point value in a dbchart. thx
ugrossAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

YodaMageCommented:
Float is type Number in Paradox.
0
jswebyCommented:
In Paradox, the Number type will be fine. If you ever use MS Access, my advice is not to use the Single type (this goes for the Single type in Delphi as well in my opinion), use the Double type.

J.
0
ugrossAuthor Commented:
hi,
thats what i thought, i now set the database field to type numeric, i now get the error that "" is not a valid integer value, i think my problem lies in these rows of code:
query1.fieldvalues['Grade'] := strtofloat(dbedit1.text);
  where the field grade is the value which will be like 4.75
0
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

YodaMageCommented:
Because FieldValues always uses Variants, it may be a somewhat slower method of accessing data, than using a field’s native format (i.e., using a field’s AsXXX property), especially in applications that process large amounts of data.

query1.fieldbyname('Grade').AsFloat := strtofloat(dbedit1.text);
0
YodaMageCommented:
You also have abug if dbeidt1.text is blank. You need something like

if (dbedit1.text = '') then dbedit1.text:= '0.00';
0
jswebyCommented:
Yes, what you're getting is an error in the conversion of a blank edit box to a Float.
0
ugrossAuthor Commented:
hi,
sorry for keepin' u waiting
i tried:
query1.fieldbyname('Grade').AsFloat := strtofloat(dbedit1.text);

but now im getting operator or semikoölon missing, thx
0
jswebyCommented:
If you have typed it in Delphi as you have typed it in here, then the line above should cause no problems.

J.
0
ugrossAuthor Commented:
hi, sorry entered the if..then code but error msg appears again and again (tried different positions already), thx
0
jswebyCommented:
The Query component is called Query1 and the Edit box is called DBEdit1, right? Can you give us the form code?

J.
0
ugrossAuthor Commented:
hi, here it is

procedure TForm1.BitBtn5Click(Sender: TObject);
begin
try
       edit1.text := intToStr(StrToInt(dbcombobox3.text) + StrToInt(dbcombobox4.text));
edit1.text := floattostr(strtofloat(edit1.text) / strtofloat(edit2.text));
dbedit1.Text := floattostr(strtofloat(edit1.text));
query1.fieldbyname('Grade')AsFloat:= strtofloat(dbedit1.text);

except
       on econverterror do messagedlg('Please check the values',mtinformation, [mbok],0);
       end;
end;
end.

let the code for the if..then statement out of the code for the moment
0
jswebyCommented:
OK. If your DBComboBoxes have their Style property set to csDropDownList, or anything other than csDropDown, then you cannot use the Text property of them. The Text property will return blank, which would explain why you are getting

'' is not a valid integer value

Either change the Style property to csDropDown or instead of reading the Text property, do the following:

Edit1.Text := IntToStr(StrToInt(DBComboBox3.Items[DBComboBox3.ItemIndex]) + StrToInt(DBComboBox4.Items[DBComboBox4.ItemIndex]));

J.
0
ugrossAuthor Commented:
sorry,
first checked how the combos r set, they r all csdropdown, then replaced my code by yours for the edit1....statement but th eprob reminas im still getting the error operator or semikolon missing
0
jswebyCommented:
When you get the error, it gives you a line number, what is the code for that line?
0
ugrossAuthor Commented:
the line is


query1.fieldbyname('Grade')asfloat:= strtofloat(dbedit1.text);
0
jswebyCommented:
GOT IT!

I finally spotted it, there's no point between the fieldname and the AsString property:

query1.fieldbyname('Grade')AsFloat:= strtofloat(dbedit1.text);

should be

query1.fieldbyname('Grade').AsFloat:= strtofloat(dbedit1.text);

Note the extra point between ('Grade') and AsFloat

J.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ugrossAuthor Commented:
aaaaaaaaaaaaaaaaaaaaaaahhhhhhhhhhhhhhhhhhhhhhhhh

thank u very much
0
YodaMageCommented:
I gave that answer about 12 comments ago.
0
RemProject ManagerCommented:
Yodamage should have had the points for this one.

When participating, play by the rules.
0
ugrossAuthor Commented:
ok, thx
hi yodamage i wiull put in a question fo ru with a similiar name, same points pls grab it
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.