Posted by WAllison on March 13, 2003
In Reply to: Mph to Mps - this is what I have so far posted by MIKE on March
13, 2003 This might help m8 let me know if it aint right - i couldn't find a comparison of any type for the results. Using a calculator everything seemed ok... heres some source: unit Main; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Menus, ComCtrls, StdCtrls; type TMainForm = class(TForm) MainStatusBar: TStatusBar; MainMenu1: TMainMenu; Exit1: TMenuItem; Exit2: TMenuItem; MphEdit: TEdit; Label1: TLabel; Label2: TLabel; MpsEdit: TEdit; ConvertButton: TButton; KmphEdit: TEdit; Label3: TLabel; procedure Exit2Click(Sender: TObject); procedure ConvertButtonClick(Sender: TObject); private { Private declarations } public { Public declarations } function MilesPerHourToMetresPerSecond(Mph: Real): Real; end; var MainForm: TMainForm; const AMile = 1606.344; implementation {$R *.dfm} function TMainForm.MilesPerHourToMetresPerSecond(Mph: Real): Real; begin KmphEdit.Text := FloatToStr(AMile*Mph); Result := AMile * Mph /60 /60; end; procedure TMainForm.Exit2Click(Sender: TObject); begin close; end; procedure TMainForm.ConvertButtonClick(Sender: TObject); begin If (MphEdit.Text <> '') or (MphEdit.Text <> null) then MpsEdit.Text := MilesPerHourToMetresPerSeond(StrToFloat(MphEdit.Text))); end; end. |
Compiling Console Applications Learn Pascal with simple Delphi Console Applications |