Recent

Author Topic: Eidt box text from function  (Read 314 times)

alaa123456789

  • Sr. Member
  • ****
  • Posts: 260
  • Try your Best to learn & help others
    • youtube:
Eidt box text from function
« on: March 03, 2024, 03:12:18 pm »
hi All

how to show the output from function in editbox
i am trying this but doesnt work

Code: Pascal  [Select][+][-]
  1. procedure TForm1.ButtonGenerateClick(Sender: TObject);
  2. begin
  3.   EditPassword.Text := GeneratePassword;
  4. end;
  5.  
  6. function GeneratePassword: string;
  7. const
  8.   Chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()';
  9. var
  10.   i: integer;
  11. begin
  12.   Randomize;
  13.   SetLength(Result, 12);
  14.   for i := 1 to 12 do
  15.     Result[i] := Chars[Random(Length(Chars)) + 1];
  16. end;
  17.  
  18.  

wp

  • Hero Member
  • *****
  • Posts: 11911
Re: Eidt box text from function
« Reply #1 on: March 03, 2024, 04:00:50 pm »
"Does't work" is not a very descriptive error message...

Your code by itself looks correct. Depending on what else is in your source file, you may have a compilation error, though, because GeneratePassword is called before it is implemented. Move the code of function "GeneratePassword" before "TForm.ButtonGenerateClick"

alaa123456789

  • Sr. Member
  • ****
  • Posts: 260
  • Try your Best to learn & help others
    • youtube:
Re: Eidt box text from function
« Reply #2 on: March 03, 2024, 04:21:43 pm »
"Does't work" is not a very descriptive error message...

Your code by itself looks correct. Depending on what else is in your source file, you may have a compilation error, though, because GeneratePassword is called before it is implemented. Move the code of function "GeneratePassword" before "TForm.ButtonGenerateClick"
thanks WP , it works now 

 

TinyPortal © 2005-2018