因为界面要符合人类的常规,所以时间位置给用户输入这样的格式:4:30 就是四个小时30分钟,但在计算时要转化为分钟,怎么办?怎么转化才得4*60+30啊?这个怎么写程序?就是如何分别取出这两个数

解决方案 »

  1.   

    Breaks a TDateTime value into hours, minutes, seconds, and milliseconds.UnitSysUtilsCategorydatetime routinesDelphi syntax:procedure DecodeTime(Time: TDateTime; var Hour, Min, Sec, MSec: Word);Delphi syntax:extern PACKAGE void __fastcall DecodeTime(const System::TDateTime DateTime, Word &Hour, Word &Min, Word &Sec, Word &MSec);DescriptionDecodeTime breaks the object specified as the Time parameter into hours, minutes, seconds, and milliseconds.This example uses a button and two labels on a form. When the user clicks the button, the current date and time are reported in the captions of the two labels.procedure TForm1.Button1Click(Sender: TObject);var
      Present: TDateTime;
      Year, Month, Day, Hour, Min, Sec, MSec: Word;
     begin
      Present:= Now;
      DecodeDate(Present, Year, Month, Day);
      Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '
        + IntToStr(Month) + ' of Year ' + IntToStr(Year);
      DecodeTime(Present, Hour, Min, Sec, MSec);
      Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '
        + IntToStr(Hour);
    end;