程式設計
題:
要如何使用delphi裡面的boolean?
星妤
2011-03-27 00:41:55 UTC
如題目,要如何使用delphi裡面的boolean?
因為寫程式的時候要用到,可是沒學過boolean的用法。
只知道他有true 跟false兩種可能。
可是我不知道怎麼寫說:什麼時候是true。
希望可以用簡單的範例。
可以跟if結合使用的話,也順便給個範例吧~
感謝大大喔 :)
一 回答:
?
2011-03-28 12:44:49 UTC
Freda兄,在您另一提問 "用delphi寫數獨" 中:
if StringGrid1.cells[j,i]='' then ......
您已不知不覺用到 boolean 了。
if - then 的語法為 if expression then statement
其中 expression 的要求就是要傳回 boolean 值。
StringGrid1.cells[j,i]='' 若成立則得到 boolean 值 True,反之得到 False;以另一種方式詮釋您的程式,應可明白:
var
bIsCellEmpty : boolean;
:
:
begin
:
:
bIsCellEmpty := StringGrid1.cells[j,i]='';
if bIsCellEmpty then
:
:
end;
ⓘ
此內容最初發佈在 Y! Answers 上,這是一個於 2021 年關閉的問答網站
Loading...