Recent

Author Topic: Is there a component like TEdit that only takes numbers in?  (Read 16468 times)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Is there a component like TEdit that only takes numbers in?
« Reply #15 on: June 30, 2012, 12:13:28 am »
Unable to multiply price with quantity for total

var
  Price: Double;
begin
    if RadioButton1.Checked then
     begin
     Price := (CurrencyEdit1.Text)  *  StrToFloat(Edit11.Text));
     CurrencyEdit2.Text:=FloatToStr(Price);

Please any idea

Text * float???
How About CurrencyEdit1.Value instead or strtoFLoat(CurrencyEdit1.Text)?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Is there a component like TEdit that only takes numbers in?
« Reply #16 on: June 30, 2012, 01:28:06 am »
Maybe something like this.

Price := StrToFloat(CurrencyEdit1.Text)  *  StrToFloat(Edit11.Text));
Lazarus Trunk / fpc 2.6.2 / Win32

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Is there a component like TEdit that only takes numbers in?
« Reply #17 on: June 30, 2012, 06:29:08 am »
There is no component like this because it is very easy to make it.

Anyway, if you are just checking about viability, feel free to work on it.
« Last Edit: June 30, 2012, 06:35:41 am by typo »

paweld

  • Hero Member
  • *****
  • Posts: 1568
Best regards / Pozdrawiam
paweld

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Is there a component like TEdit that only takes numbers in?
« Reply #19 on: July 01, 2012, 11:21:47 pm »
Mr. paweld, do you know if these controls support BiDiMode?
Lazarus Trunk / fpc 2.6.2 / Win32

paweld

  • Hero Member
  • *****
  • Posts: 1568
Re: Is there a component like TEdit that only takes numbers in?
« Reply #20 on: July 02, 2012, 01:29:43 am »
jujiboutils support BiDiMode
Best regards / Pozdrawiam
paweld

denver

  • Jr. Member
  • **
  • Posts: 67
Re: Is there a component like TEdit that only takes numbers in?
« Reply #21 on: July 02, 2012, 11:14:46 am »
Many years ago. I found an open source fnpnumericedit.pas for delphi.
I port it to lazarus. Give it a try.

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Is there a component like TEdit that only takes numbers in?
« Reply #22 on: July 07, 2012, 10:01:08 pm »
I must agree with Mr. typo on this.  This is too easy to do with code to justify adding a new component.  Just use TEdit and the OnKeyPress and add whatever keys you want to allow.
« Last Edit: July 07, 2012, 10:06:42 pm by Avishai »
Lazarus Trunk / fpc 2.6.2 / Win32

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Is there a component like TEdit that only takes numbers in?
« Reply #23 on: July 08, 2012, 12:42:46 am »
I must agree with Mr. typo on this.  This is too easy to do with code to justify adding a new component.  Just use TEdit and the OnKeyPress and add whatever keys you want to allow.


This is a very simplistic view of the problem. You do not take in to account validation (think about how many dots are allowed to be typed negative numbers ee don't accept the minus char anywhere except the 1st position) and the most difficult of all, alignment having a numeric edit that is aligned on the right and that can not be done with out creating a new component.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Is there a component like TEdit that only takes numbers in?
« Reply #24 on: July 08, 2012, 01:04:24 am »
No it is not.'and the most difficult of all, alignment having a numeric edit that is aligned on the right ' taRightJustify + Plus  'in '-' in the OnKeydown. It takes some coding. But it is a simple coding task. You simply need to think it through an write the code.  It is not that complicated.  And it is not a problem.  The reason that it has not been implanted as a control is that is is so simple to do with code and TEdit.  Write it once correctly and you never have to do it again.
« Last Edit: July 08, 2012, 01:35:25 am by Avishai »
Lazarus Trunk / fpc 2.6.2 / Win32

 

TinyPortal © 2005-2018