作者maplefog (楓霧)
看板C_and_CPP
標題Re: [問題] 求助BCB的次方問題
時間Fri Jul 10 23:19:06 2009
跟你寫的差不多,不過主要是防呆處理
在LabeledEdit1KeyPress事件中寫初步防呆處理
std::string str = "-1234567890.";
if(str.find(Key) == std::string::npos && Key != VK_BACK &&
Key != VK_TAB && Key != VK_RETURN)
Key =0;
然後加個button,在button的Click事件中寫第二次防呆處理,防止-- ..等情況
int x = StrToFloatDef(LabeledEdit1->Text,-1);
int y = StrToFloatDef(LabeledEdit2->Text,-1);
if(x!=-1 & y!=-1)
{
double a = StrToFloat(LabeledEdit1->Text);
double b = StrToFloat(LabeledEdit2->Text);
double c = pow(a,b);
}
else
{
LabeledEdit1->Text = "";
LabeledEdit2->Text = "";
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.118.207.32
※ 編輯: maplefog 來自: 140.118.207.32 (07/10 23:20)