void __fastcall TForm1::Edit1KeyPress(TObject *Sender, char &Key)
{
switch(Key)
{
case '0': //接受数字键0~9的输入
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case 8: //这是一个BackSpace键,不能禁止,否则不能实现删除功能了
break;
case '.': //检查是否已存在小数点
if(DotInStr(Edit1->Text))
Key=0;
break;
case '+': //检查是否已存在符号
case '-':
if(SignInStr(Edit1->Text))
Key=0;
break;
default: //对于其他输入键,置Key=0
Key=0;
break;
}
}