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 7643523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:28:17+00:00 2026-05-31T09:28:17+00:00

I have to solve next problem: Form23: public { Public declarations } FormsArray :

  • 0

I have to solve next problem:

Form23:

public
 { Public declarations }
 FormsArray : array of TForm24;
end;


Procedure Create_form;
begin
 SetLength(FormsArray, Length(FormsArray)+1);
 FormsArray[Length(FormsArray)-1] := TForm24.Create(Self);
end;

Form24:

public
end;

var
 UniqueValue : Array of ShortString;

Procedure Fill_Unique;
var
 tmp1 : Longint;
begin
 SetLength(UniqueValue, 256);
 for tmp1 := 0 to Length(UniqueValue)-1 do
 begin
  UniqueValue[tmp1] := IntToStr(tmp1);
 end;
end;

Procedure OnButtonClick(Sender);
begin
 Fill_Unique;
end;

When i have one form Form24 and i fill with some values, then it is ok.

When i have two forms Form24 (FormsArray[0] and FormsArray[1]) and i change UniqueValue in one form, then i have that values in two forms.

i.e.

I create FormsArray[0] and FormsArray[1]

When I click button on FormsArray[0]:

FormsArray[0] – UniqueValue[…] = ‘1,2,3,4,5,6,7,8,9…’;

FormsArray[1] – UniqueValue[…] = ‘1,2,3,4,5,6,7,8,9…’;

When I click button on FormsArray[1]:

FormsArray[0] – UniqueValue[…] = ‘1,2,3,4,5,6,7,8,9…’;

FormsArray[1] – UniqueValue[…] = ‘1,2,3,4,5,6,7,8,9…’;

When i change code to:

Form24:

public
 UniqueValue : Array of ShortString;
end;

and I click button on FormsArray[1] then i have:

FormsArray[0] – UniqueValue[…] = ”;

FormsArray[1] – UniqueValue[…] = ”;

UniqueValue is empty.

I need to have independent arrays in every forms Form24 i have created (different UniqueValue in every forms i create).

How to do this? What i do wrong?

Thanks for any help.

SOLVED !

I got -1 for solution what i write here. Then will be no solution. Search for yourself.

  • 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-31T09:28:18+00:00Added an answer on May 31, 2026 at 9:28 am

    It sounds like you’ve already solved it. Make UniqueValue be a member of the form class. Put it in the public section of the class declaration, for example.

    type
      TForm24 = class(TForm)
      public
        UniqueValue: array of string;
      end;
    

    The first code you showed has the array as a global variable, which is of course shared by all instances of your form class, as well as everything else in your program. You’re probably confused thinking that anything declared in the same file as the form class somehow “belongs to” that class, but if you think that, you’re mistaken. To make something belong to a class, it should be declared inside that class, not just somewhere in the same unit file.

    It looks like you’ll probably want to make Fill_Unique and OnButtonClick be members of the form class, too. In the code you showed, they’re standalone procedures, so they have no reference to whatever form they’re supposed to work on. That means they can’t refer to UniqueValue because they won’t know which TForm24 instance’s field to operate on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a regexp to solve the next problem: I have some
Problem is next - i have 2 entities with one-to-many relationships: public class Schema
Ok, so here's the problem I have to solve. I need to write a
I have a problem that i cant solve :( I have a user control
Here is a problem I am trying to solve: I have an irregular shape.
I'm stuck on a problem I really don't know how to solve: I have
I have been trying to solve this problem for a while, but couldn't with
I have spent some time now to solve a problem for which i have
I think I have what must be a very common problem to solve and
I'm trying to solve a problem that, unfortunately, goes beyond my capacity. I have

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.