Re: [問題] 求助BCB的次方問題
跟你寫的差不多,不過主要是防呆處理
在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)
討論串 (同標題文章)
完整討論串 (本文為第 3 之 3 篇):
2
6
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章