Jump to content
Lainkes

Editmask with variable

Recommended Posts

Hello,

 

I have an inputmask (maskedit component).

A part of the mask is the curreny year. So now users need to type the year.

Is there a way to put the current year already in the mask?

 

Thanks

 

Lainkes

Share this post


Link to post

You can use "\" to define non-replaceable characters in your mask. Thus, these characters will appear and will not be replaceable

Some like this, or another to "add "\" before each digit of year-value

uses
  DateUtils;

procedure TForm1.Button1Click(Sender: TObject);
var
  LYear: string;
begin
  for var D in YearOf(now).ToString do
    LYear := LYear + '\' + D;
  //
  MaskEdit1.Clear;
  MaskEdit1.EditMask := Format('!99/99/%s;1;_', [LYear]);   //'!99/99/' + LYear + ';1;_';
  Caption            := MaskEdit1.EditMask;
end;

image.thumb.png.75a2e5aba3e74a81ed68742af52c4bdf.png

Edited by programmerdelphi2k

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×