| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 476 人关注过本帖
标题:这个程序错在哪??????
取消只看楼主 加入收藏
MM0929
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-4-29
收藏
 问题点数:0 回复次数:0 
这个程序错在哪??????

在下照书里面copy了这段程序到机子上试,主要是通过4个按钮修改数据库表某字段的大小写,没通过,检查了N久不知错在哪,请各路高手帮看看错在哪,感激不尽!!!
源码是:
unit Unit5;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, Grids, DBGrids, StdCtrls;

type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
DataSource1: TDataSource;
Table1: TTable;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Table1CustNo: TFloatField;
Table1Company: TStringField;
Table1Addr1: TStringField;
Table1Addr2: TStringField;
Table1City: TStringField;
Table1State: TStringField;
Table1Zip: TStringField;
Table1Country: TStringField;
Table1Phone: TStringField;
Table1FAX: TStringField;
Table1TaxRate: TFloatField;
Table1Contact: TStringField;
Table1LastInvoiceDate: TDateTimeField;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function IsUpper(var ch: char): boolean;
procedure ForceCase(var TargetField:AnsiString;ToUpper: boolean);
end;

var
Form1: TForm1;

implementation
var
Upper,Mixed: boolean;
{$R *.dfm}
function TForm1.IsUpper(var ch: char): boolean;
begin
if ( (ch>='A')or(ch <= 'Z')) then
Result := true
else
Result := false;
end;
procedure TForm1.ForceCase(var TargetField:AnsiString;ToUpper: boolean);
var
WorkBuffer: String;
i: Integer;
begin
Table1.DisableControls;
try
Table1.First; //将记录指针移到第一条记录处
while not EOF do
begin
WorkBuffer:=(AnsiString)(FieldByName(TargetField));
if ToUpper then
begin
for i:=0 to strlen(WorkBuffer)-1 do
WorkBuffer[i] := UpCase(WorkBuffer[i]);
end
else
begin
for i := 0 to strlen(WorkBuffer) - 1 do
if IsUpper(WorkBuffer[i]) then
WorkBuffer[i]:=(Ansichar)(ord(WorkBuffer[i]) + 32);
WorkBuffer[1]:=UpCase(WorkBuffer[1]);
end;
Table1.Edit;
FieldByName((AnsiString)(TargetField)):= WorkBuffer;
Table1.Post;
Table1.Next;
Table1.EnableControls;
end;
finally
Table1.EnableControls;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);//第一个地址大写
begin
ForceCase('Addr1',Upper);
end;
procedure TForm1.Button2Click(Sender: TObject);//第二个地址大写
begin
ForceCase('Addr2',Upper);
end;
procedure TForm1.Button3Click(Sender: TObject);//第一个地址大小写互换
begin
ForceCase('Addr1',Upper);
end;
procedure TForm1.Button4Click(Sender: TObject);//第二个地址大小写互换
begin
ForceCase('Addr2',Upper);
end;
end.

错误提示如下:
[Error] Unit5.pas(67): '(' expected but ')' found
[Error] Unit5.pas(67): ')' expected but ';' found
[Error] Unit5.pas(70): Incompatible types: 'String' and 'PAnsiChar'
[Error] Unit5.pas(75): Incompatible types: 'String' and 'PAnsiChar'
[Error] Unit5.pas(77): '(' expected but ')' found
[Error] Unit5.pas(77): ')' expected but ';' found
[Error] Unit5.pas(81): '(' expected but ')' found
[Error] Unit5.pas(92): Constant object cannot be passed as var parameter

2006-05-05 04:04
快速回复:这个程序错在哪??????
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.059199 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved