home *** CD-ROM | disk | FTP | other *** search
- program ConvertIt;
-
- uses System.Windows.Forms;
-
- type
- ConvertForm = class (Form)
- private
- ResultList: ListBox;
- CelsiusEdit: NumericUpDown;
- public
- constructor Create;
- procedure Convert (Sender: TObject; Args: EventArgs);
- end;
-
- function CelsiusToFahrenheit (AValue: Double): Double;
- begin
- Result := ((AValue * 9) / 5) + 32;
- end;
-
- procedure ConvertForm.Convert (Sender: TObject; Args: EventArgs);
- var
- LCelsius: Double;
- begin
- LCelsius := System.Convert.ToDouble (CelsiusEdit.Value);
- with ResultList do begin
- BeginUpdate;
- Items.Clear;
- Items.Add (System.Convert.ToString ('Celsius = ' + System.Convert.ToString (LCelsius)));
- Items.Add(System.Convert.ToString ('Fahrenheit = ' + System.Convert.ToString (CelsiusToFahrenheit (LCelsius))));
- Items.Add (System.Convert.ToString ('Kelvin = ' + System.Convert.ToString (LCelsius + 273.15)));
- EndUpdate;
- end;
- end;
-
- constructor ConvertForm.Create;
- begin
- Inherited Create;
- Width := 240; Height := 320;
- CelsiusEdit := NumericUpDown.Create;
- with CelsiusEdit do begin
- Left := 8; Top := 8; Width := 217;
- Value := System.Convert.ToDecimal (100.0);
- Maximum := System.Convert.ToDecimal(10000.0);
- Minimum := System.Convert.ToDecimal(-1000.0);
- Add_ValueChanged (EventHandler.Create (Self, NativeInt (@ConvertForm.Convert)));
- end;
-
- ResultList := ListBox.Create;
- with ResultList do begin
- Left := 8; Top := 40; Width := 217; Height := 217;
- end;
-
- Text := 'Temp Converter';
- Controls.Add (CelsiusEdit);
- Controls.Add (ResultList);
- StartPosition := FormStartPosition.CenterScreen;
- Convert (Nil, Nil);
- end;
-
- begin
- Application.Run (ConvertForm.Create);
- end.
-