头晕,不想动。帮偶写个函数吧。得到结果就结贴

wofan 2004-09-29 12:30:08
判断一变量
如果为''返回0
否则返回原值

...全文
65 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
梅青松 2004-09-29
  • 打赏
  • 举报
回复
接分啦
savagexyz 2004-09-29
  • 打赏
  • 举报
回复
呵呵,接分
liufuyahong 2004-09-29
  • 打赏
  • 举报
回复
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, FR_Class, StdCtrls;

type
TForm1 = class(TForm)
frReport1: TfrReport;
Button1: TButton;
procedure Button1Click(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
Function fullto0(v:Variant):Variant;


end;

var
Form1: TForm1;

implementation

{$R *.dfm}



procedure TForm1.Button1Click(Sender: TObject);
var
v:Variant;
begin
v:=1;
ShowMessage(VarToStr(fullto0(v)));
v:='';
ShowMessage(VarToStr(fullto0(v)));
end;

function TForm1.fullto0(v: Variant): Variant;
begin
Result:=v;
if VarToStr(v)='' then
Result:=0 ;
end;


end.
angelface 2004-09-29
  • 打赏
  • 举报
回复
那我可得接!
wofan 2004-09-29
  • 打赏
  • 举报
回复
俺知道写对了,今天有点懒。不想动脑子,嘿嘿

当送分玩
yueyixing 2004-09-29
  • 打赏
  • 举报
回复
稍等,捎上俺。谢谢
todouwang 2004-09-29
  • 打赏
  • 举报
回复
Function fullto0(srstr:string):string;
begin
if srstr='' then
result:=0;
end;
纯冰糖 2004-09-29
  • 打赏
  • 举报
回复
你自己都写对了啊
纯冰糖 2004-09-29
  • 打赏
  • 举报
回复
你写的正确啊
wofan 2004-09-29
  • 打赏
  • 举报
回复
Function fullto0(srstr:string):string;
begin
if srstr='' then
result:='0'
else
result:=srstr;
end;

哎,头疼得要命。非要自己写

也没人可怜一下俺

来一个人给分啦

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧