Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Edit(Count).text?

  1. #1
    2710 is offline Programmer
    Join Date
    Sep 2008
    Posts
    108
    Rep Power
    0

    Edit(Count).text?

    Hi all,

    firstly I just want to say sorry for so many posts! This board is so dead that it makes me look bad posting so much lol.

    Ok, so anyways, I had like ten edit boxes. Edit1, Edit2 ... Edit10

    So I do a for count:

    for count : 1 to 10
    do
    begin
    if edit(count).text = ' ';
    then edit(count).color := clRed;

    But, the program wont let me do it, I get an error. It doesnt like the 'edit(count)' part. Is there any other way to check every edit box?

    Thanks

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Edit(Count).text?

    Try this:
    Code:
      for i:= 0 to (ComponentCount - 1) do
      begin
        if (Components[i] is TEdit) then
        begin
          if TEdit(Components[i]).text = '' then
            TEdit(Components[i]).color := clRed;
        end;
      end;
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    2710 is offline Programmer
    Join Date
    Sep 2008
    Posts
    108
    Rep Power
    0

    Re: Edit(Count).text?

    Umm...:

    undeclared Identifier: 'ComponentCount'
    undeclared identifier: 'Components'

    Do I have to declare these under the variables?

    Thanks

  5. #4
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Edit(Count).text?

    Identical components on Delphi form: components array
    Components and ComponentCount are variables in your form.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  6. #5
    2710 is offline Programmer
    Join Date
    Sep 2008
    Posts
    108
    Rep Power
    0

    Re: Edit(Count).text?

    So can you tell me what to write? Coz the link you gave me doesn't tell me what to put under variables.

    Var

    Components: ???;
    ComponentCount: Integer;

    Thanks

  7. #6
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Edit(Count).text?

    As long as you've inherited from TForm, they already exist.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  8. #7
    2710 is offline Programmer
    Join Date
    Sep 2008
    Posts
    108
    Rep Power
    0

    Re: Edit(Count).text?

    But it doesnt work

    Edit: What does inheritied mean? My form is called Form1

  9. #8
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Edit(Count).text?

    Can you paste your full code?
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  10. #9
    2710 is offline Programmer
    Join Date
    Sep 2008
    Posts
    108
    Rep Power
    0

    Re: Edit(Count).text?

    Here ya go:

    Code:
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    
    type
      TForm1 = class(TForm)
        Label1: TLabel;
        Edit1: TEdit;
        Edit2: TEdit;
        Edit3: TEdit;
        Edit4: TEdit;
        Label2: TLabel;
        Label3: TLabel;
        Label4: TLabel;
        Label5: TLabel;
        Label6: TLabel;
        Label7: TLabel;
        Label8: TLabel;
        Edit5: TEdit;
        Edit6: TEdit;
        Edit7: TEdit;
        Label9: TLabel;
        g: TEdit;
        Button1: TButton;
        Label10: TLabel;
        Edit9: TEdit;
        Edit10: TEdit;
        Label11: TLabel;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure Readonlycol;
    var Count: Integer;
    begin
    
    for count:= 0 to (Componentcount-1)
     do
      begin
        if (Components[count] is TEdit)
         then
          begin
           if Tedit(Components[count]).readonly = true
            then
              Tedit(Components[count]).color := clRed;
          end;
      end
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    if (edit1.Text <> '') and (edit2.Text <> '')
      then
        begin
          edit3.ReadOnly:= true;
          edit4.ReadOnly:= true;
        end
      else
        begin
          edit3.ReadOnly:= false;
          edit4.ReadOnly:= false;
        end;
    
    unit1.Readonlycol;
    
    end;
    
    end.
    Thanks!

  11. #10
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Edit(Count).text?

    Your procedure wasn't declared part of your form, so you didn't have access to your form's variables. Try this:
    Code:
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    
    type
      TForm1 = class(TForm)
        Label1: TLabel;
        Edit1: TEdit;
        Edit2: TEdit;
        Edit3: TEdit;
        Edit4: TEdit;
        Label2: TLabel;
        Label3: TLabel;
        Label4: TLabel;
        Label5: TLabel;
        Label6: TLabel;
        Label7: TLabel;
        Label8: TLabel;
        Edit5: TEdit;
        Edit6: TEdit;
        Edit7: TEdit;
        Label9: TLabel;
        g: TEdit;
        Button1: TButton;
        Label10: TLabel;
        Edit9: TEdit;
        Edit10: TEdit;
        Label11: TLabel;
        procedure Button1Click(Sender: TObject);
        procedure Readonlycol;
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.Readonlycol;
    var Count: Integer;
    begin
    
    for count:= 0 to (Componentcount-1)
     do
      begin
        if (Components[count] is TEdit)
         then
          begin
           if Tedit(Components[count]).readonly = true
            then
              Tedit(Components[count]).color := clRed;
          end;
      end
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    if (edit1.Text <> '') and (edit2.Text <> '')
      then
        begin
          edit3.ReadOnly:= true;
          edit4.ReadOnly:= true;
        end
      else
        begin
          edit3.ReadOnly:= false;
          edit4.ReadOnly:= false;
        end;
    
    Readonlycol;
    
    end;
    
    end.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

Closed Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 10-10-2010, 11:06 AM
  2. Replies: 4
    Last Post: 09-29-2010, 09:26 AM
  3. Edit text file on server.
    By Logan in forum Visual Basic Programming
    Replies: 1
    Last Post: 08-04-2010, 01:59 AM
  4. Column count doesn't match value count at row 1
    By msebar in forum PHP Development
    Replies: 2
    Last Post: 12-29-2009, 07:42 AM
  5. Column count doesn't match value count at row 1
    By shiyam198 in forum PHP Development
    Replies: 7
    Last Post: 09-07-2008, 12:13 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts