
关于C++builder控件button的问题 30
设定一个button和Edit(有且只有一个)在Edit中输入10进制数,按下button后Edit中数字变成16进制再按一下Edit用变成10进制10与16进制互相转换...
设定一个button和Edit(有且只有一个)
在Edit中输入10进制数,按下button后Edit中数字变成16进制
再按一下 Edit用变成10进制
10与16进制互相转换的代码我已经写好了
但是不知道怎样按一下变成16进制 再按一下变成10进制
EditRes->Text=IntToHex(StrToInt(EditRes->Text),1);
EditRes->Text=StrToInt("$"+EditRes->Text);
另外 如何加入异常处理啊 展开
在Edit中输入10进制数,按下button后Edit中数字变成16进制
再按一下 Edit用变成10进制
10与16进制互相转换的代码我已经写好了
但是不知道怎样按一下变成16进制 再按一下变成10进制
EditRes->Text=IntToHex(StrToInt(EditRes->Text),1);
EditRes->Text=StrToInt("$"+EditRes->Text);
另外 如何加入异常处理啊 展开
1个回答
展开全部
class TForm1 : public TForm
{
__published: // IDE-managed Components
TEdit *EditRes;
TButton *Button1;
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
bool bDecimal;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
void __fastcall TForm1::Button1Click(TObject *Sender)
{
bDecimal = !bDecimal;
try
{
if (bDecimal)
EditRes->Text = IntToHex(StrToInt(EditRes->Text),1);
else
EditRes->Text = StrToInt("$" + EditRes->Text);
}
catch(Exception& e)
{
ShowMessage(e.Message);
}
}
{
__published: // IDE-managed Components
TEdit *EditRes;
TButton *Button1;
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
bool bDecimal;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
void __fastcall TForm1::Button1Click(TObject *Sender)
{
bDecimal = !bDecimal;
try
{
if (bDecimal)
EditRes->Text = IntToHex(StrToInt(EditRes->Text),1);
else
EditRes->Text = StrToInt("$" + EditRes->Text);
}
catch(Exception& e)
{
ShowMessage(e.Message);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询