那个帖子上不来了,只好再发一个
两位朋友提供的源代码中都没有考虑除数为0的情况
我的思路和后一位朋友的相似我在1/x按钮中添加的代码如下:
procedure TForm1.Button1xClick(Sender: TObject);
begin
if (StrToFloat(Screen.Text) = 0) then
begin
Screen.Text := '不能运算';
end
else if (Screen.Text <> '') then
Screen.Text := FloatToStr(1 / StrToFloat(Screen.Text))
else
Screen.Text := '不能运算';
end;
但是这样不是很好,为空的仍然报错,我不明白错在哪,盼望高手指教还有一个问题,每次运行程序的位置怎么设定
还有按钮上文字的颜色怎么更改?我在Font属性里改成蓝色的,但是很奇怪还是黑色的
form1的Font属性也改成蓝色的了,如果改字体和粗细都是可以的
还有我想让Screen(就是Edit1)里的文字是右靠齐的怎么做呢?TButton和TSpeedButton有什么区别呢?
两位朋友提供的源代码中都没有考虑除数为0的情况
我的思路和后一位朋友的相似我在1/x按钮中添加的代码如下:
procedure TForm1.Button1xClick(Sender: TObject);
begin
if (StrToFloat(Screen.Text) = 0) then
begin
Screen.Text := '不能运算';
end
else if (Screen.Text <> '') then
Screen.Text := FloatToStr(1 / StrToFloat(Screen.Text))
else
Screen.Text := '不能运算';
end;
但是这样不是很好,为空的仍然报错,我不明白错在哪,盼望高手指教还有一个问题,每次运行程序的位置怎么设定
还有按钮上文字的颜色怎么更改?我在Font属性里改成蓝色的,但是很奇怪还是黑色的
form1的Font属性也改成蓝色的了,如果改字体和粗细都是可以的
还有我想让Screen(就是Edit1)里的文字是右靠齐的怎么做呢?TButton和TSpeedButton有什么区别呢?
窗体颜色是FONT属性
两个按钮是一个可以加图片一个不能
我没有找到打开位置的设置地方,不好意思,偶.....笨....
我想改按钮上字体的颜色,但是改不了
可以试试下面的代码:
procedure TForm1.Button1xClick(Sender: TObject);
begin
if (trim(screen.text) = '0') or (screen.text = '') or (screen.text = null) then
begin
Screen.Text := '不能运算';
end
else begin
Screen.Text := FloatToStr(1 / StrToFloat(Screen.Text));
end; end;
如下:
function StrToFloatDef(Str: string; Def: Float): Float;例如:
StrToFloatDef('123.3', 0);//返回123.3
StrToFloatDef('23ac', 0); //返回0
不过Tbitbtn和tspeedbutton都可以;bitbtn和speedbutton都是从button类中派生出来的;继承了butto的一些属性并有一些button类所不具有的功能;譬如字体颜色的更改;还有设置图片之类的;^_^;