pascalabcnet/InstallerSamples/Graphics/Controls/cc18_SimpleCalc.pas
Mikhalkovich Stanislav 5404728fdb case s of
'1'
end

допускаются символы в case по строкам
2020-08-01 11:29:09 +03:00

44 lines
1.3 KiB
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Модуль Controls - Калькулятор
uses Controls,GraphWPF;
begin
Window.Title := 'Калькулятор с выводом в TextBox';
LeftPanel(150, Colors.Orange);
var tb := SetMainControl.AsTextBox;
tb.FontSize := 30;
var x := IntegerBox('X:');
var y := IntegerBox('Y:');
x.Value := Random(0,10);
y.Value := Random(0,10);
var cb := new ComboBoxWPF('Операция');
cb.AddRange('+','-','*','/');
var count := 0;
var sb := StatusBar;
sb.Text := 'Количество вычислений: ' + count;
var b := Button('+');
b.Click := procedure -> begin
case cb.SelectedText of
'+': tb.Println($'{x.Value} + {y.Value} = {x.Value + y.Value}');
'-': tb.Println($'{x.Value} - {y.Value} = {x.Value - y.Value}');
'*': tb.Println($'{x.Value} * {y.Value} = {x.Value * y.Value}');
'/': tb.Println($'{x.Value} / {y.Value} = {x.Value / y.Value}');
end;
x.Value := Random(0,10);
y.Value := Random(0,10);
count += 1;
sb.Text := 'Количество вычислений: ' + count;
end;
Button('Очистить').Click := () -> begin
count := 0;
sb.Text := 'Количество вычислений: ' + count;
tb.Clear;
end;
cb.SelectionChanged := procedure -> begin
b.Text := cb.SelectedText
end;
end.