Formatar Data

Delphi

17/10/2006

Gostaria que a medida que fosse digitando uma data ela fosse colocando as barras automaticamente

Ex:

Se eu digitar 17 já acrescente a ´/´ automaticamente
Se eu digitar 10 acrescente a outra ´/´
Se eu digitar 2006 verificar se a data informada é válida e pular o foco para o próximo campo

então ficaria 17/10/2006 já com o foco em outro campo


Visualdesigner

Visualdesigner

Curtidas 0

Respostas

Steve_narancic

Steve_narancic

17/10/2006

proque você não usa um maskedit, ou o componente JVDateEdit no JEDI


GOSTEI 0
Visualdesigner

Visualdesigner

17/10/2006

Já usei a propriedade Mask do Field, já usei o maskedit, só que em determinadas situacoes e necessito utilizar dessa forma


GOSTEI 0
Output

Output

17/10/2006

Tentaew:

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if key = #8 then
exit;
if Length(edit1.text) = 2 then
   begin
   edit1.text:= edit1.text + ´/´;
   edit1.SelStart:= Length(edit1.text);
   end;
if Length(edit1.text) = 5 then
   begin
   edit1.text:= edit1.text + ´/´;
   edit1.SelStart:= Length(edit1.text);
   end;
end;



GOSTEI 0
POSTAR