StringGrid的欄位 B=A-C 問題 |
答題得分者是:max5020
|
lovemari
中階會員 發表:134 回覆:224 積分:76 註冊:2005-08-18 發送簡訊給我 |
各位大大好 小弟在寫StringGrid的欄位 搜尋出 A , B 那C的部分想要 C = A - B 就寫以下SQL , 但是結果跑出來卻是 C = B 能請各位大大幫我看看那裡出錯了嗎?? [code delphi] for a:=1 to StringGrid1.RowCount-1 do if StringGrid1.Cells[2,a] = '' then StringGrid1.Cells[2,a] := FloattoStr(StrToFloat(StringGrid1.Cells[1,a]) - (StrToFloat(StringGrid1.Cells[3,a]))); [/code]
------
Program : Delphi 7 DataBase : Oracle 9i Client : ClientDataSet |
max5020
資深會員 發表:30 回覆:277 積分:321 註冊:2003-06-04 發送簡訊給我 |
你這樣寫好像是 B(2) = A(1) - C(3)
如果C(3)是空值, 那不就是 B(2) = A(1) 是不是要改成 StringGrid1.Cells[3,a] := FloattoStr(StrToFloat(StringGrid1.Cells[1,a]) - (StrToFloat(StringGrid1.Cells[2,a]))); 我猜的啦!!! ===================引 用 lovemari 文 章=================== 各位大大好 小弟在寫StringGrid的欄位 搜尋出 A , B 那C的部分想要 C = A - B 就寫以下SQL , 但是結果跑出來卻是 C = B 能請各位大大幫我看看那裡出錯了嗎?? [code delphi] for a:=1 to StringGrid1.RowCount-1 do if StringGrid1.Cells[2,a] = '' then StringGrid1.Cells[2,a] := FloattoStr(StrToFloat(StringGrid1.Cells[1,a]) - (StrToFloat(StringGrid1.Cells[3,a]))); [/code] |
lovemari
中階會員 發表:134 回覆:224 積分:76 註冊:2005-08-18 發送簡訊給我 |
小弟改成這樣 依然跑出 C = B 耶
[code delphi] for a:=1 to StringGrid1.RowCount-1 do // if StringGrid1.Cells[2,a] = '' then StringGrid1.Cells[2,a] := FloattoStr(StrToFloat(StringGrid1.Cells[1,a]) - (StrToFloat(StringGrid1.Cells[3,a]))); [/code]
------
Program : Delphi 7 DataBase : Oracle 9i Client : ClientDataSet |
P.D.
版主 發表:603 回覆:4038 積分:3874 註冊:2006-10-31 發送簡訊給我 |
1. max5020 已經說的很明白了, 但我沒有看到你改了那裡, 只是 remark 一行而已
2.這段叫做 CODE, 不叫做 SQL , 上一下YAHOO, GOOGLE 查一下何謂 SQL? 3.看不出來你的程式能跑出 C = B 的結論, 因為永遠是 B = 右列的計算式, 要做到 C = 右列計算式, 想想看如何設定吧! ===================引 用 lovemari 文 章=================== 小弟改成這樣 依然跑出 C = B 耶 [code delphi] for a:=1 to StringGrid1.RowCount-1 do // if StringGrid1.Cells[2,a] = '' then StringGrid1.Cells[2,a] := FloattoStr(StrToFloat(StringGrid1.Cells[1,a]) - (StrToFloat(StringGrid1.Cells[3,a]))); [/code] |
lovemari
中階會員 發表:134 回覆:224 積分:76 註冊:2005-08-18 發送簡訊給我 |
抱歉抱歉 我可能敘述上有錯誤
我的 Cells[1,a] = A Cells[2,a] = B Cells[3,a] = C 我想要 B = A - C (一開始敘述不夠清楚讓大家以為我要 C = A - B) 那我把 IF xxxxx = '' 這行code 刪除 在按照 max5020 大大的 改成這樣依然跑出 B = C (而非 A - C ) [code delphi] for a:=1 to StringGrid1.RowCount-1 do StringGrid1.Cells[2,a] := FloattoStr(StrToFloat(StringGrid1.Cells[1,a]) - (StrToFloat(StringGrid1.Cells[3,a]))); [/code] ===================引 用 P.D. 文 章=================== 1. max5020 已經說的很明白了, 但我沒有看到你改了那裡, 只是 remark 一行而已 2.這段叫做 CODE, 不叫做 SQL , 上一下YAHOO, GOOGLE 查一下何謂 SQL? 3.看不出來你的程式能跑出 C = B 的結論, 因為永遠是 B = 右列的計算式, 要做到 C = 右列計算式, 想想看如何設定吧!
------
Program : Delphi 7 DataBase : Oracle 9i Client : ClientDataSet
編輯記錄
lovemari 重新編輯於 2008-04-16 08:36:50, 註解 無‧
|
max5020
資深會員 發表:30 回覆:277 積分:321 註冊:2003-06-04 發送簡訊給我 |
Use Cells to access the string within a particular cell. ACol is the column coordinate of the cell, and ARow is the row coordinate of the cell. The first row is row zero, and the first column is column zero.
我終於知道你要問什麼了, 改成下列這樣 [code delphi] for a:=1 to StringGrid1.RowCount-1 do StringGrid1.Cells[1,a] := FloattoStr(StrToFloat(StringGrid1.Cells[0,a]) - (StrToFloat(StringGrid1.Cells[2,a]))); [/code] 因為是從0開始, 不是從1開始數!! ===================引 用 lovemari 文 章=================== 抱歉抱歉 我可能敘述上有錯誤 我的 Cells[1,a] = A Cells[2,a] = B Cells[3,a] = C 我想要 B = A - C (一開始敘述不夠清楚讓大家以為我要 C = A - B) 那我把 IF xxxxx = '' 這行code 刪除 在按照 max5020 大大的 改成這樣依然跑出 B = C (而非 A - C ) [code delphi] for a:=1 to StringGrid1.RowCount-1 do StringGrid1.Cells[2,a] := FloattoStr(StrToFloat(StringGrid1.Cells[1,a]) - (StrToFloat(StringGrid1.Cells[3,a]))); [/code] ===================引 用 P.D. 文 章=================== 1. max5020 已經說的很明白了, 但我沒有看到你改了那裡, 只是 remark 一行而已 2.這段叫做 CODE, 不叫做 SQL , 上一下YAHOO, GOOGLE 查一下何謂 SQL? 3.看不出來你的程式能跑出 C = B 的結論, 因為永遠是 B = 右列的計算式, 要做到 C = 右列計算式, 想想看如何設定吧! |
lovemari
中階會員 發表:134 回覆:224 積分:76 註冊:2005-08-18 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |