case query1.FieldByName('SVC_CD').AsString of
'C' : StringGrid1.Cells[1,i] := '011';
'H' : StringGrid1.Cells[1,i] := '017';
'0' : StringGrid1.Cells[1,i] := '010';
'6' : StringGrid1.Cells[1,i] := '016';
'8' : StringGrid1.Cells[1,i] := '018';
'9' : StringGrid1.Cells[1,i] := '019';
end;
요렇게 비교하고 싶은데 제목처럼 오류가 나요.
고수님들 조언 부탁드리겠습니다.
만약에 하신다면
이렇게하면 되지 않을까요
aaa:char;
aaa:=Query1.FieldbyName('SVC_CD').AsSting
case aaa of
....
end;
이게 안된다면 if 문을 쓸수밖에 없는것 같은데....
그럼 수고 하세요
아래는 help 내용입니다.
The case statement provides a readable alternative to complex nested if conditionals. A case statement has the form
case selectorExpression of
caseList1: statement1;
...
caseListn: statementn;
end
where selectorExpression is any expression of an ordinal type (string types are invalid) and each caseList is one of the following:
A numeral, declared constant, or other expression that the compiler can evaluate without executing your program. It must be of an ordinal type compatible with selectorExpression.
Thus 7, True, 4 + 5 * 3, 'A', and Integer('A') can all be used as caseLists,
but variables and most function calls cannot. (A few built-in functions like Hi and Lo can occur in a caseList. See Constant expressions.)
Other examples of case statements:
case MyColor of
Red: X := 1;
Green: X := 2;
Blue: X := 3;
Yellow, Orange, Black: X := 0;
end;
case Selection of
Done: Form1.Close;
Compute: CalculateTotal(UnitCost, Quantity);
else
Beep;
end;