if EditName.Text = '' then
   begin
      Application.MessageBox('请输入用户的姓名!','提示信息',MB_OK+MB_ICONINFORMATION);
      Exit;
   end;   if EditBirthdate.Text = '' then
   begin
      Application.MessageBox('请输入用户的出生日期!','提示信息',MB_OK+MB_ICONINFORMATION);
      Exit;
   end;   //EditBIRTHDATE.Text := GetSolidStr(EditBIRTHDATE.Text);
   if (not(Length(EditBIRTHDATE.Text) in [8..10])) or ( Pos('/', EditBIRTHDATE.Text) <> 5 ) then
   begin
      Application.MessageBox('请您输入4位年号,年号、月份和日期用‘/’隔开。', '输入',MB_OK);
      EditBIRTHDATE.SetFocus;
      EditBIRTHDATE.SelectAll;
      exit;
   end
   else
   begin
     try
        EditBIRTHDATE.Text := DateToStr(StrToDate(EditBIRTHDATE.Text));
        EditAge.Text := InttoStr(YearsBetween(Now(),StrtoDate(EditBirthDate.Text)));
     except
        Application.MessageBox('您输入的日期不对 !', '输入', MB_OK);
        EditBIRTHDATE.SetFocus;
        EditBIRTHDATE.SelectAll;
        exit;
     end;
   end;
为什么每次输入都提示'请您输入4位年号,年号、月份和日期用‘/’隔开,明明是按照要求却为什么不对阿

解决方案 »

  1.   

    我看你还是这样吧
    try 
      StrToDate(Edit1.Text);
    except
      ShowMessge('');
    end;
      

  2.   

    跟踪一下看看你EditBIRTHDATE.TEXT究竟是什么东东。不过你这样的判断确实不是很准确啊!
      

  3.   

    EditBIRTHDATE.TEXT就是Tedit,主要是要限制输入的时间格式,有没有别的方法可以代替这个功能阿,请各位指教
      

  4.   

    procedure TFrm_SMSServer.Timer1Timer(Sender: TObject);
    var
      s: AnsiString;
      ReturnCode,MsgSize,i :integer;
      SMSContent1,SMSContent2:string;
      SIMEI,SIMEINO,SContent,responsestr:string;
      msgstr:pchar;PContent:Cardinal;
    begin
    SetLength(s, 1024 * 1024);
    FillChar(s[1], 1024 * 1024, #0);
    msgstr := @s[1];
    ReturnCode := SkReceive(MDPHandle, pchar(AMsgID), msgstr, MsgSize);
    if returncode=0 then
      responsestr:=string(msgstr);
    lbprocesses.items.add(Format('返回码为:%d', [ReturnCode]));
    //lbprocesses.items.add('短信内容为: '+responsestr);
    //lbprocesses.items.add('序列号为: '+AMsgID);
    try
        Keys:=Translage(Responsestr);
        for i:=0 to keys.Count-1 do
        try
          item:=PSkRecvItem(keys.Objects[i]);
          if keys[i]<>'' then
          begin
               try
                    SIMEINO:=item^.Mobile  ; //接收手机号码
                    PContent:=item^.Position  ;//接收短信序列号
                    SContent:=item^.Content  ;  //接收短信内容
                    SMSContent2:=item^.Time  ;  //接收短信时间
                    AMsgID:=inttostr(PContent);  //传递短信序列号,实现每次都读取最新短信
                   try
                     CurrentDir :=getcurrentdir;
                     if copy(CurrentDir,length(CurrentDir),1)<>'\' then
                     CurrentDir := CurrentDir + '\';
                     YJ1000Ini := TIniFile.Create(CurrentDir+'YJ2000SMSSer.INI');
                     YJ1000Ini.writestring('serverset','Amsgid','AMsgID');  //2007zhou将最新短信序列号写入配置文件
                   finally
                      YJ1000Ini.Free;
                   end;
                    //lbProcesses.Items.Add('序列号为: '+AMsgID+' 手机号为: '+SIMEINO);
               except
               end ;
          end;
        finally
        end;
    请各位帮忙看看,为什么不能写入配置文件