Topic: ID code

Hi
Is there a scrip that a textbox should only consist of 10 digits and if you insert more or less than 10 digits, it shows an error?
What I want to do is to record personnel number for each employee
thanks

Re: ID code

You could do something like this.

Procedure something;
var
    
    lngth : integer;
begin

  lngth :=  Length(Form1.Edit1.text); //check how many digits have been entered

  if lngth <> 10 then
   begin
     messageDlg('Personnel Number  must be 10 digits ',mtError, mbCancel, 0); //your choice of message and buttons
     Form1.Edit1.SetFocus; // Make the edit box the focus - so the correct number can be typed in
   end;
   
On a clear disk you can seek forever

Re: ID code

thanks for your fast reply
unfortunately I got error for this script.
can you please attach a sample?

Re: ID code

Hi Identity, Hi CDB,
Another approach you could try is to disable the 'save' button until the personnel no' is the correct length (see attached).
Derek.

Post's attachments

Attachment icon field length.zip 336.88 kb, 190 downloads since 2022-06-13 

Re: ID code

Интересное решение. То есть если использовать данный скрипт и Exel не нужен? Или данный скрипт для Exel предназначен.

Блог вебмастера

6 (edited by k245 2022-06-14 10:08:03)

Re: ID code

alecs175 wrote:

Интересное решение. То есть если использовать данный скрипт и Exel не нужен? Или данный скрипт для Exel предназначен.

Интересное решение - это писать вопросы на русском языке в англоязычной ветке форума, толком даже не разобравшись в сути топика и тематике форума wink 


The script is intended to be used inside My Visual Database.

Визуальное программирование: блог и телеграм-канал.

7 (edited by vovka3003 2022-06-14 10:40:25)

Re: ID code

k245 wrote:

Интересное решение - это писать вопросы на русском языке в англоязычной ветке форума, толком даже не разобравшись в сути топика и тематике форума wink

Это говнобот же...  smile В анкете так и написано.

Re: ID code

identity wrote:

I got error for this script.

What error did you get? There should be an extra END;  at the bottom of the script, which I didn't put in.

On a clear disk you can seek forever