type TSonFontStyle = set of TFontStyle;.... Include(TSonFontStyle,SomeValue);
for I:=0 to length(charcount)-1 do begin {LUOIB fsBold, fsItalic, fsUnderline, fsStrikeOut} ch:=charcount[i]; case ch of 'L':include(TSonFontStyle,fsUnderline); 'U':include(TSonFontStyle,fsUnderline); 'O':include(TSonFontStyle,fsStrikeOut); 'I':include(TSonFontStyle,fsItalic); 'B':include(TSonFontStyle,fsbold); end; end;我这样写错在那里
同意楼上,补充: type TSonFontStyle = set of TFontStyle;procedure TForm1.Button1Click(Sender: TObject); var F:TSonFontStyle; begin Include(f, fsItalic); f:=f+[fsUnderline,fsStrikeOut]; end;
Case语句的选择因子必须是有顺类型,而不能用非有序类型的如字符传作为选择因子!
procedure TForm1.Button1Click(Sender: TObject); var F:TSonFontStyle; i:integer; ch:char; charcount:string; begin Include(f, fsItalic); f:=f+[fsUnderline,fsStrikeOut]; for I:=0 to length(charcount)-1 do begin {LUOIB fsBold, fsItalic, fsUnderline, fsStrikeOut} ch:=charcount[i]; case ch of 'L':include(F,fsUnderline); 'U':include(F,fsUnderline); 'O':include(F,fsStrikeOut); 'I':include(F,fsItalic); 'B':include(F,fsbold); end; end; end;
Include(TSonFontStyle,SomeValue);
begin
{LUOIB fsBold, fsItalic, fsUnderline, fsStrikeOut}
ch:=charcount[i];
case ch of
'L':include(TSonFontStyle,fsUnderline);
'U':include(TSonFontStyle,fsUnderline);
'O':include(TSonFontStyle,fsStrikeOut);
'I':include(TSonFontStyle,fsItalic);
'B':include(TSonFontStyle,fsbold);
end;
end;我这样写错在那里
type TSonFontStyle = set of TFontStyle;procedure TForm1.Button1Click(Sender: TObject);
var
F:TSonFontStyle;
begin
Include(f, fsItalic);
f:=f+[fsUnderline,fsStrikeOut];
end;
var
F:TSonFontStyle;
i:integer;
ch:char;
charcount:string;
begin
Include(f, fsItalic);
f:=f+[fsUnderline,fsStrikeOut];
for I:=0 to length(charcount)-1 do
begin
{LUOIB fsBold, fsItalic, fsUnderline, fsStrikeOut}
ch:=charcount[i];
case ch of
'L':include(F,fsUnderline);
'U':include(F,fsUnderline);
'O':include(F,fsStrikeOut);
'I':include(F,fsItalic);
'B':include(F,fsbold);
end;
end;
end;