Please help me with this problem!
I am new with Delphi, and arrays I just can't understand
I need to write program that contain the arrays for colours
My first problem is to increment the colour count
Those are my declarations

procedure btnSelectClick(Sender: TObject);
    { Private declarations }
    CountSelection : array [1..7] of integer ;
    { Public declarations }
        nCount  : Integer;
  frmRainbow: TfrmRainbow;
  TheRainbow : array [1..7] of string = ('Red', 'Orange',
            'Yellow', 'Green', 'Blue', 'Indigo','Violet');

I declared the nCount in the event FormCrate

procedure TfrmRainbow.FormCreate(Sender: TObject);
  nCount : Integer;
  for nCount := 1 to 7 do
    CountSelection[nCount] := 0;

and then on btnSelectClick I add code

   nSelect : Integer;
   nTotal  : Integer;
   Index   : integer;
  //Select a random number to identify the colour selected//this works
  //increment the colour count//???
  nCount := 0;
nCount := nCount + 1;
   lblNumberSelections.Caption := 'Number of Selectons: '
                               + IntToStr(nCount);

but it will only increment by one. What I am doing wrong?

Then I must add counts for each of the colours (stored in the array) and determine the number of colour selections made thus far. How?????????

My next problem is showButton: It clears the existing display in the ListBox, and then displays the counts for each of the colours as stored in the array. Items are added to the ListBox
And then where the user will click on the reset button it must zero each of the array.

Please help me!!!!!!!!!!!!!
Could you suggest any good book (or site on the internet)with planty of examples for programs written in Delphi. It could help me a lot.
thanks to eveybody who could help me!!!!!!!!

Recommended Answers

All 5 Replies

regarding books and links, search on the forum, me and other users made some sticky threads.

i'm in a rush and i don't have time to debug your code. try to use breakpoints and delphi's watch.

best regards,

Is this a school assignment?

If so, please post the assignment, I'm finding it difficult to understand what exactly you need done.

I remember when I first learned to code, seeing a working example was the best way to learn...
However, once you get beyond the basics, you can do it on your own

Yes it was a school assignment.
I agree with you that the best way to learn is to refer to other source codes, but unfortunately I don’t know any good site on the internet, where I can find some similar examples. Everywhere I have looked they have some advanced programs, and I am just beginner. That’s why I asked if somebody can propose some good books, or internet sites, that I can look at. And I don’t want anybody to do it for me (like radu84 implied). I want to learn, but if you don’t have anybody who could help you at the start it’s really difficult.
Thank you for your interest in my problem. It’s nice to know that somebody else understand and want to help.:)

i'm not sure that i understand what you're saying. i told you at this moment i can not take your code and debug it, and i suggested you to try to debug by yourself, using debugger. correct me if i'm wrong.

and also i told you to search on the forum because i made and thread where i put some links where you cand find delphi documentation. you can find bellow the link

have you took a look at that?

also a good site, where you can learn very easy delphi is .

best regards,

Sorry! I look like I missed understood you. I am just to tired, frustrated, and I took much more than I can hanle. (12 subjects if much to much)
Thanks for the links.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.