今天女朋友的一门课,要求用delphi 软件编程,内容是一个计算器。当然,这个工作肯定是落在我的头上了。

这个软件是我第一次使用,边自学边进行代码编写,在n多次修改完善之后,终于成形。功能不是很多,跟C#很相似,但发现之前有很多在专业课中没有实现的功能,颇有成就感。

 unit jisuanqi;
//王永维,实现简单的加减乘除计算
interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls; type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
Button10: TButton;
Button11: TButton;
Button12: TButton;
Button13: TButton;
Button14: TButton;
Button15: TButton;
Button16: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Button12Click(Sender: TObject);
procedure Button13Click(Sender: TObject);
procedure Button14Click(Sender: TObject);
procedure Button15Click(Sender: TObject);
procedure Button16Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1;
shu1,shu2:Integer;
Shu11,Shu22:String;
fuhao:String;
shu1changdu,shu2changdu:Integer; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.Text :=edit1.Text+'';
end; procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text :=edit1.Text+'';
end; procedure TForm1.Button3Click(Sender: TObject);
begin
edit1.Text :=edit1.Text+'';
end; procedure TForm1.Button4Click(Sender: TObject);
begin
edit1.Text :=edit1.Text+'';
end; procedure TForm1.Button5Click(Sender: TObject);
begin
edit1.Text :=edit1.Text+'';
end; procedure TForm1.Button6Click(Sender: TObject);
begin
edit1.Text :=edit1.Text+'';
end; procedure TForm1.Button7Click(Sender: TObject);
begin
edit1.Text :=edit1.Text+'';
end; procedure TForm1.Button8Click(Sender: TObject);
begin
edit1.Text :=edit1.Text+'';
end; procedure TForm1.Button9Click(Sender: TObject);
begin
edit1.Text :=edit1.Text+'';
end; procedure TForm1.Button10Click(Sender: TObject);
begin
edit1.Text :=edit1.Text+'';
end; procedure TForm1.Button11Click(Sender: TObject);
begin
edit1.Text :='';
end; procedure TForm1.Button12Click(Sender: TObject);
begin
Shu11:=Edit1.text;
shu1changdu:=length(Shu11);
shu1:=StrtoInt(Edit1.text); //将字符串转变为整型
edit1.Text :=edit1.Text+'+';
fuhao:='+';
end; procedure TForm1.Button13Click(Sender: TObject);
begin
Shu11:=Edit1.text;
shu1changdu:=length(Shu11);
shu1:=StrtoInt(Edit1.text); //将字符串转变为整型
edit1.Text :=edit1.Text+'-';
fuhao:='-';
end; procedure TForm1.Button14Click(Sender: TObject);
begin
Shu11:=Edit1.text;
shu1changdu:=length(Shu11);
shu1:=StrtoInt(Edit1.text); //将字符串转变为整型
edit1.Text :=edit1.Text+'*';
fuhao:='*';
end; procedure TForm1.Button15Click(Sender: TObject);
begin
Shu11:=Edit1.text;
shu1changdu:=length(Shu11);
shu1:=StrtoInt(Edit1.text); //将字符串转变为整型
edit1.Text :=edit1.Text+'/';
fuhao:='/';
end; procedure TForm1.Button16Click(Sender: TObject);
begin
Shu22:=Edit1.text;
shu2changdu:=length(Shu22); if fuhao='+' then
begin
Shu22:=copy(Shu22,shu1changdu+,shu2changdu); //截取出第二个数
shu2:=StrtoInt(Shu22); //将字符串转化为整形
edit1.Text :=InttoStr(shu1+shu2);
end;
if fuhao='-' then
begin
Shu22:=copy(Shu22,shu1changdu+,shu2changdu); //截取出第二个数
shu2:=StrtoInt(Shu22); //将字符串转变为整型
edit1.Text :=InttoStr(shu1-shu2);
end;
if fuhao='*' then
begin
Shu22:=copy(Shu22,shu1changdu+,shu2changdu); //截取出第二个数
shu2:=StrtoInt(Shu22); //将字符串转变为整型
edit1.Text :=InttoStr(shu1*shu2);
end;
if fuhao='/' then
begin
Shu22:=copy(Shu22,shu1changdu+,shu2changdu); //截取出第二个数
shu2:=StrtoInt(Shu22); //将字符串转变为整型
edit1.Text :=InttoStr(shu1 Div shu2);
end;
fuhao:='';
end; end.

初学delphi的更多相关文章

  1. 初学 Delphi 嵌入汇编[1] - 汇编语言与机器语言

    非科班出身, 现在才接触汇编, 惭愧呀, 好好学! 主选课本是清华大学王爽老师的<汇编语言>. 推荐 王爽老师的汇编网 汇编语言之前是机器语言. 机器语言是机器指令的集合, 机器指令是一系 ...

  2. Delphi的BPL介绍和使用 转

    了解BPL和DLL的关系将有助于我们更好地理解DELPHI在构件制作.运用和动态.静态编译的工作方式.对初学DELPHI但仍对DELPHI开发不甚清晰的朋友有一定帮助.BPL vs. DLL(原文ht ...

  3. Delphi在win7/vista下写注册表等需要管理员权限的解决方案

    看到论坛好多人问win7下写注册表的问题,我结合自己的理解写了一点东西,首先声明一下,本人初学Delphi,水平有限,大家见笑了,有什么不对之处请老鸟多指点. [背景]win7/Vista提供的UAC ...

  4. DELPHI的BPL使用

    了解BPL和DLL的关系将有助于我们更好地理解DELPHI在构件制作.运用和动态.静态编译的工作方式.对初学DELPHI但仍对DELPHI开发不甚清晰的朋友有一定帮助.第一部分:有关包的介绍 一般我们 ...

  5. 在DELPHI中动态创建控件以及控件的事件

    在DELPHI中我们经常要动态的创建控件以及控件的事件.例如,我们可能想根据程序需要动态的创建一些Tshape组件来创建某个图形,并使得在鼠标移动上去之后可以完成某些操作.这一般需要需要三步: 生成一 ...

  6. delphi7开发webservice部属在apache服务器中 转

    delphi7开发webservice部属在apache服务器中 delphi7 webservice apache 用Delphi7开发Web Service程序,并把服务程序放在apache We ...

  7. Qt: 记事本源代码

    界面编程之实例学习,系统记事本是个极好的参考,初学Delphi及后之c#,皆以记事本为参考,今以Qt学习,亦是如此. 期间搭建开发环境,复习c++知识,寻找模块对应功能,不一而足:现刻录其模块代码,以 ...

  8. Delphi初学者应小心的六大陷阱

    Delphi初学者应小心的六大陷阱   作者:子夜编译       初学DelphiI的人,由于各种原因,对DelphiI中的许多概念不能很好的理解,并由此带来了许多的问题,或者是开发出的程序稳性不好 ...

  9. 【Java二十周年】Delphi转行java的一些小感触

    本文纯属一届小码农对java使用过程的体验感触 目录: 初遇java编程语言 与java的擦肩 深入java 跨平台性 开源支持 web的支撑 初遇java编程语言 刚上大学的时候,完全是个电脑盲.刚 ...

随机推荐

  1. 使用Python自带difflib模块进行文件内容差异对比

    difflib_text.py #!/usr/bin/python import difflib import sys try: textfile1=sys.argv[1] textfile2=sys ...

  2. NgDL:第四周深层神经网络

    4.3核对矩阵维数 根据前向的矩阵,可以计算出右上的规律,对于第L层的w来说,其维数为(n[L],n[L-1]),n[L]表示第L层的单元数. 4.4为什么深层神经网络会好用? 如果要做一个人脸识别的 ...

  3. 25-Python3 错误和异常

    25-Python3 错误和异常 ''' 语法错误 ''' # while True print('hello,runoob') ''' 异常 ''' ##ZeroDivisionError # pr ...

  4. [Java in NetBeans] Lesson 02. Variables, Data Types and Assignment.

    这个课程的参考视频在youtube. 主要学到的知识点有: Data Type: int, char, String, double, boolean. When into printf, int ( ...

  5. 左右两栏div布局,高度自适应

    页面结构如下: <div class="container"> <div class="left"> left </div> ...

  6. iOS UI基础-10.0 QQ聊天布局之键盘及文本使用

    要实现的效果:   这里只说用到的几个知识点 1.图片包含文字 在设置文字的Frame的时候,使用背景(按钮)的尺寸,文字使用了内边距 背景图片,使用拉伸 /** * 返回一张可以随意拉伸不变形的图片 ...

  7. cocos2d-x C++ iOS工程集成第三方支付宝支付功能

      一.在支付宝开放平台下载支付宝SDK(https://doc.open.alipay.com/doc2/detail.htm?spm=a219a.7629140.0.0.WWgVz8&tr ...

  8. Nuxtjs初始

    今天去看vue的官网,才看了他的升级版-->Nuxtjs,https://nuxtjs.org/guide/installation可以点击链接进入他的官网查看文档 第一步,搭建项目之前的准备工 ...

  9. Lepus(天兔)监控MySQL部署

    http://www.dbarun.com/docs/lepus/install/lnmp/ 注意:xampp mysqldb-python版本太高会导致lepus白屏 apache版本最好选择2.2 ...

  10. SQL中的关联更新和关联删除

    在SQL中,经常用到关联查询,比如select a.* from A a inner join B b on a.PId=b.FId where 条件,SQL中也支持类似的关联更新和关联删除. 关联更 ...