31-01-2018, 11:13 PM
السلام عليكم ورحمة الله
في Lazarus fpc 2.6.0
في دلفي
في Lazarus fpc 2.6.0
كود :
procedure TForm1.Button1Click(Sender: TObject);
begin
case edit1.Text of
'one': caption := 'one';
'111': caption := '1';
end;
end;كود :
function CaseOfString(s: string; a: array of string): Integer;
begin
Result := 0;
while (Result < Length(a)) and (a[Result] <> s) do
Inc(Result);
if a[Result] <> s then
Result := -1;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
case CaseOfString(Edit1.Text, ['42', '23', 'nerd alert', 'hello world']) of
0: Label1.Caption := 'What is ?';
1: Label1.Caption := 'Tow';
2: Label1.Caption := 'yes';
3: Label1.Caption := 'Hello';
else
Label1.Caption := '?';
end;
end;