線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1176
推到 Plurk!
推到 Facebook!

条件语句 出错

答題得分者是:ahentseng
wq236589
一般會員


發表:21
回覆:37
積分:16
註冊:2008-08-27

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-09-04 11:27:42 IP:123.181.xxx.xxx 訂閱

[code delphi]
var l:string;
if l='0' then
shape11.Brush.Color:=clRed and shape14.Brush.Color:=clRed
else if l= '1' then //101
shape11.Brush.Color:=clYellow and shape14.Brush.Color:=clYellow;
else if l='2' then //103
shape11.Brush.Color:=clLime and shape14.Brush.Color:=clLime
else if l='-1' then //105
shape11.Brush.Color:=clWhite and shape14.Brush.Color:=clWhite
else if l='3' then //107
if Shape11.Brush.Color=clWhite then
shape11.Brush.Color:=clYellow and shape14.Brush.Color:=clYellow
else shape11.Brush.Color:=clWhite and shape14.Brush.Color:=clWhite //110
else if l='4' then //111
if Shape11.Brush.Color=clWhite then
shape11.Brush.Color:=clLime and shape14.Brush.Color:=clLime
else shape11.Brush.Color:=clWhite and shape14.Brush.Color:=clWhite; //114
[/code]
报错
[Error] Unit2.pas(101): Operator not applicable to this operand type
[Error] Unit2.pas(103): Operator not applicable to this operand type
[Error] Unit2.pas(105): Operator not applicable to this operand type
[Error] Unit2.pas(107): Operator not applicable to this operand type
[Error] Unit2.pas(110): Operator not applicable to this operand type
[Error] Unit2.pas(111): Operator not applicable to this operand type
[Error] Unit2.pas(114): Operator not applicable to this operand type
[Error] Unit2.pas(114): Operator not applicable to this operand type
我的 条件语句有错吗? 知道连报错原因一起回答一下谢谢
还有我用case语句试过 报错 (必须为有序变量)
L是通过数据库获取的值代码我就不写了
ahentseng
一般會員


發表:6
回覆:9
積分:13
註冊:2008-03-19

發送簡訊給我
#2 引用回覆 回覆 發表時間:2008-09-04 11:50:52 IP:59.120.xxx.xxx 訂閱
麻煩請用begin..end包住...這種基礎是書上就有教的

if l='0' then
begin
shape11.Brush.Color:=clRed;
shape14.Brush.Color:=clRed;
end;
以此類推
如果要使用Case...也很簡單
如果L裡面的值確定都是數字的話
Case StrToInt(L) of 將L轉換成數字就可以使用了
連這種錯誤都不去想...不去自己找...學習程式是很難有進步的
===================引 用 wq236589 文 章===================

[code delphi]
var l:string;
if l='0' then
shape11.Brush.Color:=clRed and shape14.Brush.Color:=clRed

[/code]
報錯
[Error] Unit2.pas(101): Operator not applicable to this operand type
[Error] Unit2.pas(103): Operator not applicable to this operand type
[Error] Unit2.pas(105): Operator not applicable to this operand type
[Error] Unit2.pas(107): Operator not applicable to this operand type
[Error] Unit2.pas(110): Operator not applicable to this operand type
[Error] Unit2.pas(111): Operator not applicable to this operand type
[Error] Unit2.pas(114): Operator not applicable to this operand type
[Error] Unit2.pas(114): Operator not applicable to this operand type
我的 條件語句有錯嗎? 知道連報錯原因一起回答一下謝謝
還有我用case語句試過 報錯 (必須為有序變量)
L是通過資料庫獲取的值代碼我就不寫了
編輯記錄
ahentseng 重新編輯於 2008-09-04 11:57:17, 註解 無‧
wq236589
一般會員


發表:21
回覆:37
積分:16
註冊:2008-08-27

發送簡訊給我
#3 引用回覆 回覆 發表時間:2008-09-04 12:35:59 IP:123.181.xxx.xxx 訂閱
不好意思!问题已经找到 and用的不是地方
系統時間:2024-05-03 5:21:40
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!