你好,欢迎来到电脑编程技巧与维护杂志社! 杂志社简介广告服务读者反馈编程社区  
合订本订阅
 
 
您的位置:技术专栏 / 办公应用专栏
第一个delphi for php的小程序:简单加法(1)
 
今天花了一个小时写了一个小程序,我的delphi php的第一个程序。功能是在浏览器上显示一道简单的加法题,用户可以输入答案,电脑会告诉你正确或者错误,然后可以再来一题。功能很简单,主要为了熟悉delphi for php,写的时候,不时地查阅php帮助,发现这次codegear的php帮助做的还是不错的。

  程序如下:

//Includes
require_once(”vcl/vcl.inc.php”);
use_unit(”forms.inc.php”);
use_unit(”extctrls.inc.php”);
use_unit(”stdctrls.inc.php”);
  //Class definition
class Unit3 extends Page
{
public $txtAnswer = null;
public $btnB = null;
public $btnA = null;
public $btnRun = null;
public $lblMsg = null;
public $Button4 = null;
public $Button2 = null;
  function btnRunClick($sender, $params)
{
$a=rand(1,9);
$b=rand(1,9);
  $this->btnA->Caption=$a;
$this->btnB->Caption=$b;
  $this->lblMsg->Caption=” “;
$this->txtAnswer->Text=” “;
  }
  function txtAnswerSubmit($sender, $params)
{
global $a;
global $b;
global $c0;
global $c1;
  $a=$this->btnA->Caption;
$b=$this->btnB->Caption;
$c0=$a+$b;
$c1=$this->txtAnswer->Text;
  if ($c0==$c1){$this->lblMsg->Caption=”Right”;
} else {$this->lblMsg->Caption=”Wrong”;
}
  }
  }
  global $application;
  global $Unit3;
  //Creates the form
$Unit3=new Unit3($application);
  //Read from resource file
$Unit3->loadResource(__FILE__);
  //Shows the form
$Unit3->show();
  ?>

(编辑:aniston)

  推荐精品文章

·2024年2月目录 
·2024年1月目录
·2023年12月目录
·2023年11月目录
·2023年10月目录
·2023年9月目录 
·2023年8月目录 
·2023年7月目录
·2023年6月目录 
·2023年5月目录
·2023年4月目录 
·2023年3月目录 
·2023年2月目录 
·2023年1月目录 

  联系方式
TEL:010-82561037
Fax: 010-82561614
QQ: 100164630
Mail:gaojian@comprg.com.cn

  友情链接
 
Copyright 2001-2010, www.comprg.com.cn, All Rights Reserved
京ICP备14022230号-1,电话/传真:010-82561037 82561614 ,Mail:gaojian@comprg.com.cn
地址:北京市海淀区远大路20号宝蓝大厦E座704,邮编:100089