Board index » delphi » Help: invalid typecast

Help: invalid typecast

Please help me,

I have several combo boxes (cb1..cb10)  and want in a function to add
some (1 to t ) of the combobox.text to one string.

I tried almost everything but get always a invalid typecast error or
page fault error.
I want something like this:
----------------
function tform1.makestring(t:integer):string;
var x:integer;a:string;
begin
   a:='';
   for x := 1 to t do
   begin
      a := a+',' +  tcombobox('cb' + inttostr(t) + '.text') ;
   end;
   result := a;
end;
----------------
regards,
Albert

Please sent also a mail because my news server is not reliable.

Albjan_No_Sp...@telebyte.nl
(Remove: _No_Spam_)

 

Re:Help: invalid typecast


Quote
Albert wrote:

> Please help me,

> I have several combo boxes (cb1..cb10)  and want in a function to add
> some (1 to t ) of the combobox.text to one string.

> I tried almost everything but get always a invalid typecast error or
> page fault error.
> I want something like this:
> ----------------
> function tform1.makestring(t:integer):string;
> var x:integer;a:string;
> begin
>    a:='';
>    for x := 1 to t do
>    begin
>       a := a+',' +  tcombobox('cb' + inttostr(t) + '.text') ;
>    end;
>    result := a;
> end;

Try:

 a := a + ',' +  TCombobox('cb' + IntToStr(t)).Text;

Hope that does it..

Rkr

--
                   \|||/
                   /'^'\
                  ( 0 0 )
--------------oOOO--(_)--OOOo--------------
. Reid Roman                              .
. Delphi Programmer / Analyst             .
. TVisualBasic:=class(None);              .
. May the Source be With You              .
-------------------------------------------
. Auto-By-Tel (http://www.autobytel.com)  .
. Irvine, CA U.S.A                        .
. E-Mail : rkroman (at) pacbell (dot) net .
. or reidr (at) autobytel (dot) com       .
-------------------------------------------

Re:Help: invalid typecast


Albert,
  Try something like:

function tform1.makestring(t:integer):string;
var x:integer;a:string;
begin
   a:='';
   for x := 1 to t do
   begin
      a := a+',' +  tcombobox(FindComponent('cb' + inttostr(t))).text ;
   end;
   result := a;
end;

Hope this helps!
--

Rodney E Geraghty
GERA-Tech
Ottawa, Canada
gera...@ibm.net

Albert <Albjan_No_Sp...@telebyte.nl> wrote in article
<34a0432b.13210...@news.telebyte.nl>...

Quote
> Please help me,

> I have several combo boxes (cb1..cb10)  and want in a function to add
> some (1 to t ) of the combobox.text to one string.

> I tried almost everything but get always a invalid typecast error or
> page fault error.
> I want something like this:
> ----------------
> function tform1.makestring(t:integer):string;
> var x:integer;a:string;
> begin
>    a:='';
>    for x := 1 to t do
>    begin
>       a := a+',' +  tcombobox('cb' + inttostr(t) + '.text') ;
>    end;
>    result := a;
> end;
> ----------------
> regards,
> Albert

> Please sent also a mail because my news server is not reliable.

> Albjan_No_Sp...@telebyte.nl
> (Remove: _No_Spam_)

Re:Help: invalid typecast


Quote
In article <34a0432b.13210...@news.telebyte.nl>, Albjan_No_Sp...@telebyte.nl wrote:
>Please help me,

>      a := a+',' +  tcombobox('cb' + inttostr(t) + '.text') ;

a := A + ',' + TCOMBOBOX(cb + IntToStr(t)).Text;

The Graphical Gnome (r...@ktibv.nl)
Sr. Software Engineer IT Department
-----------------------------------------
The Unofficial Delphi Developers FAQ
http://www.gnomehome.demon.nl/uddf/index.htm

Re:Help: invalid typecast


On 24 Dec 97 01:59:50 GMT, "Rodney E Geraghty" <gera...@ibm.net>
wrote:

Quote
>  Albert,
>  Try something like:
>   a := a+',' +  tcombobox(FindComponent('cb' + inttostr(t))).text ;

>  Hope this helps!

Yes it works, the FindComponent () was the final solution

To you and all the others who helped  me with the problem:
Thanks for the quick and accurate suggestions.

Albert

Albjan_No_Sp...@telebyte.nl
(Remove: _No_Spam_)

Other Threads