Board index » cppbuilder » Ensuring an edit control contains numbers only

Ensuring an edit control contains numbers only

Is there any way that an edit control can be set up (or checked) so that
it only accepts integers? In my example, I have an edit box which
appears on a page of my wizard and when the 'Next>' button is pressed, I
want to ensure that the value that has been added into the edit box is a
number. Hope someone can help - I'm hoping it has been done before!

Thanks for your time,

Sinead Armstrong (Ireland)

 

Re:Ensuring an edit control contains numbers only


void __fastcall TForm1::Edit1KeyPress(TObject *Sender, char &Key)
{
  if(!isdigit(Key))
  {
    Key = 0;
    Beep();
  }

Quote
}

Ciao
"Sinead Armstrong" <sinead.armstr...@sse.ie> ha scritto nel messaggio
news:3B4EB614.E590AF6@sse.ie...
Quote
> Is there any way that an edit control can be set up (or checked) so that
> it only accepts integers? In my example, I have an edit box which
> appears on a page of my wizard and when the 'Next>' button is pressed, I
> want to ensure that the value that has been added into the edit box is a
> number. Hope someone can help - I'm hoping it has been done before!

> Thanks for your time,

> Sinead Armstrong (Ireland)

Re:Ensuring an edit control contains numbers only


Grazie mille, Paolo!

Sinead

Quote
PaoloItaly wrote:
> void __fastcall TForm1::Edit1KeyPress(TObject *Sender, char &Key)
> {
>   if(!isdigit(Key))
>   {
>     Key = 0;
>     Beep();
>   }
> }

> Ciao
> "Sinead Armstrong" <sinead.armstr...@sse.ie> ha scritto nel messaggio
> news:3B4EB614.E590AF6@sse.ie...
> > Is there any way that an edit control can be set up (or checked) so that
> > it only accepts integers? In my example, I have an edit box which
> > appears on a page of my wizard and when the 'Next>' button is pressed, I
> > want to ensure that the value that has been added into the edit box is a
> > number. Hope someone can help - I'm hoping it has been done before!

> > Thanks for your time,

> > Sinead Armstrong (Ireland)

Other Threads