Announcement

Collapse
No announcement yet.

Problem mit Zuweisung

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem mit Zuweisung

    Hallo alle zusammen,

    ich habe bei mir ein ernstes Problem.

    Ich habe 2 Formulare, das 1. Willkommensscreen durch einen Button gelangt man auf das 2. Spielebene.

    In dem 2. Formular hab ich 26 Buttons, so nun will ich diese 26 Buttons einfach einem Array mit Buttons zuweisen damit ich sie nachher mittels einer scheife durchgehen kann (ich will sie wieder sichtbar machen ist jetzt aber nicht notwendig das ihr das wisst!!)

    private

    TButton *btn[25];

    so nun wo sollte ich diese Zuweisung hinschreiben oder muss ich vorher noch was machen?

    btn[0]=btn_a;
    btn[1]=btn_b;
    btn[2]=btn_c;
    btn[3]=btn_d;
    btn[4]=btn_e;
    btn[5]=btn_f;
    btn[6]=btn_g;
    btn[7]=btn_h;
    btn[8]=btn_i;
    btn[9]=btn_j;
    btn[10]=btn_k;
    btn[11]=btn_l;
    btn[12]=btn_m;
    btn[13]=btn_n;
    btn[14]=btn_o;
    btn[15]=btn_p;
    btn[16]=btn_q;
    btn[17]=btn_r;
    btn[18]=btn_s;
    btn[19]=btn_t;
    btn[20]=btn_u;
    btn[21]=btn_v;
    btn[22]=btn_w;
    btn[23]=btn_x;
    btn[24]=btn_y;
    btn[25]=btn_z;

  • #2
    Da das Folgende funktioniert, muss dein Problem woanders liegen:


    //---------------------------------------------------------------------------

    #ifndef Unit1H
    #define Unit1H
    //---------------------------------------------------------------------------
    #include <Classes.hpp>
    #include <Controls.hpp>
    #include <StdCtrls.hpp>
    #include <Forms.hpp>
    //---------------------------------------------------------------------------
    class TForm1 : public TForm
    {
    __published: // Von der IDE verwaltete Komponenten
    TButton *Button1;
    TButton *Button2;
    private: // Benutzer-Deklarationen
    TButton *myArray[2];
    public: // Benutzer-Deklarationen
    __fastcall TForm1(TComponent* Owner);
    };
    //---------------------------------------------------------------------------
    extern PACKAGE TForm1 *Form1;
    //---------------------------------------------------------------------------
    #endif

    //---------------------------------------------------------------------------

    #include <vcl.h>
    #pragma hdrstop

    #include "Unit1.h"
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma resource "*.dfm"
    TForm1 *Form1;
    //---------------------------------------------------------------------------
    __fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
    {

    myArray[0]=Button1;
    myArray[1]=Button2;
    myArray[0]->Caption="Hello";
    }
    //---------------------------------------------------------------------------
    Christian

    Comment


    • #3
      Wenn Du btn[25]=btn_z; weglaesst gehts.
      Du hast 25 Elemente reserviert. Das ist Index 0..24.

      Comment


      • #4
        genial (Es ist einfach murks, dass Text hier 10 Zeichen lang sein muss)
        Christian

        Comment


        • #5
          OMG so dumm wie ich is keiner auf der WELT!!!!!!


          ich hatte bei meiner zuweisung tausendmal rumkopiert!! und dabei hab ich sowies ausieht irgendwo einen verschwinden lassen also hatte ich einfach oben
          in privat nur 25 für eigentlich 26 Buttons gemacht !! wie er sagt

          0-24 und ich brauchte ja 0-25 mannnn bin ich ein DEPP!!!!!!


          danke nomma

          Comment

          Working...
          X