peterhowells

Email Address Generator

Mar 10th, 2022 (edited)
1,897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.24 KB | None | 0 0
  1. procedure TfrmMain.btnGenerateClick(Sender: TObject);
  2. var
  3.   iSpacePos: integer;
  4.   sFullName, sFirstInit, sSecondInit, sYear, sEmail: string;
  5.  
  6. begin
  7.   sFullName := edtFullName.Text;
  8.   iSpacePos := pos(' ', sFullName);
  9.  
  10.   sFirstInit := AnsiLowerCase(copy(sFullName, 1, 3));
  11.   sSecondInit := AnsiLowerCase(copy(sFullName, iSpacePos + 1, 3));
  12.   sYear := copy(edtYear.Text, 3, 4);
  13.   //sYear := copy(IntToStr(sedYear.Value), 3, 4);    // if using the spin edit component instead of the edit box
  14.  
  15.   sEmail := 'Email Address: ' + sFirstInit + sSecondInit + sYear +
  16.     '@northwoodschool.co.za';
  17.  
  18.   lblEmailAddress.Caption := sEmail;
  19.  
  20.   // for debugging
  21.   //lblEmailAddress.Caption := IntToStr(iSpacePos);
  22.   //lblEmailAddress.Caption := sSecondInit;
  23. end;
  24.  
  25. procedure TfrmMain.FormCreate(Sender: TObject);
  26. begin
  27.   frmMain.Caption := 'EAGen';
  28.   lblNameMessage.Caption := 'Enter your full name';
  29.   lblYear.Caption := 'Enter your matric year';
  30.   edtYear.Text := '2024';
  31.   edtFullName.Text := '';
  32.   btnGenerate.Caption := 'Generate';
  33.   lblEmailAddress.Caption := '';
  34.   pnlHeading.Caption := 'Email Address Generator';
  35.   pnlHeading.Font.Style := [fsBold];
  36.  
  37.   //sedYear.Value := 2024;
  38.   //sedYear.MaxValue := 2030;
  39.   //sedYear.MinValue := 2022;
  40. end;
  41.  
Advertisement