Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4097364
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:09:52+00:00 2026-05-20T20:09:52+00:00

I am writing a small password generator and have 4 CheckBoxes for the combinations,

  • 0

I am writing a small password generator and have 4 CheckBoxes for the combinations, these are: Upper Case Letters, Lower Case Letters, Numbers and Special Characters.

My question is – do I have to go through each possible combination of CheckBoxes in the logic with “if” statements or is there a quicker, more simple way that could shorten the code more?

I am sorry if this question is rather silly, but it will really help me in the future to learn from this if indeed there is a better way.

All the best

Chris ( shamballa ).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T20:09:53+00:00Added an answer on May 20, 2026 at 8:09 pm

    Why do you think which you must through each possible combination of CheckBoxes?

    check this basic function.

    Suppose do you have 4 checkboxes called CbUpper, CbLower, CbNumbers, CbSymbols.

    Now you can construct a function like this

    function Generate(AllowUpper,AllowLower,AllowNumbers,AllowSymbols:Boolean; PassLen:Integer):AnsiString;
    const
      UpperList  = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
      LowerList  = 'abcdefghijklmnopqrstuvwxyz';
      NumberList = '0123456789';
      SymbolList = '@#()=¿?!¡[]';
    var
      MyList  : AnsiString;
      Index   : Integer;
      i       : Integer;
    begin
      Result:='';
      MyList:='';
       //here if the flag is set the elements are added to the main array (string) to process
       if AllowUpper   then MyList:=MyList + UpperList;
       if AllowLower   then MyList:=MyList + LowerList;
       if AllowNumbers then MyList:=MyList + NumberList;
       if AllowSymbols then MyList:=MyList + SymbolList;
    
       Randomize;
       if Length(MyList)>0 then
         for i:= 1 to PassLen do
         begin
          Index:=Random(Length(MyList))+1;
          Result:=Result+MyList[Index];
         end;
    end;
    

    and call in this way

    Var
      MyPassword : AnsiString;
    begin
       MyPassword:=Generate(CbUpper.Checked,CbLower.Checked,CbNumbers.Checked,CbSymbols.Checked,20);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a small app which I need to test with utf-8 characters
I'm currenty writing small application for image processing. However I have a big problem
I am writing a small module which will have several different aspects to it,
I'm currently writing a small test Android app, and have run across a small
I am writing a small procedure. I have a cursor called c1 , and
I am currently writing a small calendar in ASP.Net C#. Currently to produce the
I'm writing a small tool in C# which will need to send and receive
I'm writing a small web server in Python, using BaseHTTPServer and a custom subclass
I'm writing a small article on humanly readable alternatives to Guids/UIDs, for example those
I'm writing a small application in VB.NET and I would like some of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.