不用Strtodate 还有其他方法吗?

解决方案 »

  1.   

    EncodeDatevar
      MyDate: TDateTime;
    begin
      MyDate := EncodeDate(StrToInt(Edit1.Text), StrToInt(Edit2.Text), StrToInt(Edit3.Text));
      Label1.Caption := DateToStr(MyDate);
    end;
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);var
      MyDate: TDateTime;
    begin
      MyDate := EncodeDate(StrToInt(Edit1.Text), StrToInt(Edit2.Text), StrToInt(Edit3.Text));
      Label1.Caption := DateToStr(MyDate);
    end;
      

  3.   

    有啊
    EncodeDate 是把年月日生成一个日期
    procedure TForm1.Button1Click(Sender: TObject);var
      MyDate: TDateTime;
    begin
      MyDate := EncodeDate(StrToInt(Edit1.Text), StrToInt(Edit2.Text), StrToInt(Edit3.Text));
      Label1.Caption := DateToStr(MyDate);
    end;
    Decodedate 是把数字合成一个日期
    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;
      

  4.   

    比如从’abcdefg‘得到C以后的子串
      

  5.   

    function Pos(Substr: string; S: string): Integer;
    function Copy(S; Index, Count: Integer): string;
      

  6.   

    用copy啊
    var s:string;
    begin
      s:='123456789' ;
      edit1.Text:=copy(s,4,length(s));
    end;
      

  7.   

    pos 是返回字符所在的位置
    var s:string;
    begin
      s:='dhdhduiaaa';
      edit1.Text:=inttostr(pos('i',s));
    end;
      

  8.   

    UnitSysUtilsCategorydate/time routinesfunction EncodeDate(Year, Month, Day: Word): TDateTime;
    function TryEncodeDate(Year, Month, Day: Word; out Date: TDateTime): Boolean;DescriptionEncodeDate returns a TDateTime value from the values specified as the Year, Month, and Day parameters.The year must be between 1 and 9999.Valid Month values are 1 through 12.Valid Day values are 1 through 28, 29, 30, or 31, depending on the Month value. For example, the possible Day values for month 2 (February) are 1 through 28 or 1 through 29, depending on whether or not the Year value specifies a leap year.If the specified values are not within range, EncodeDate raises an EConvertError exception.TryEncodeDate is identical to EncodeDate, except that TryEncodeDate responds to out of range parameters by returning False instead of raising an exception.
      

  9.   

    procedure TForm1.Button1Click(Sender: TObject);var
      s: string;
      temp: string;
      i: integer;
    begin
      s := 'abcdefg';
      temp := '';
      for i := 1 to length(s) do
        if (s[i] <> 'c') then
          temp := temp + s[i]    else
        begin
          if trim(temp) <> '' then
            showmessage(trim(temp)); //把trim(temp)放到你想要的地方。
          temp := '';
        end;
      if trim(temp) <> '' then
        showmessage(trim(temp)); //把trim(temp)放到你想要的地方。
    end;