Forum Discussion

Jerryth's avatar
Jerryth
Occasional Contributor
7 years ago
Solved

TC Form Listbox not working

I have a TC form with a listbox containing a couple of entries.

 

This line in a script works correctly adding a new entry at the bottom of the existing entries:

UserForms.AutoTestRandomForm.JewelLB.Items.Add('33');

 

All of these lines generate the same error:

UserForms.AutoTestRandomForm.JewelLB.Items[1].Text := '99';

ShowMessage(UserForms.AutoTestRandomForm.JewelLB.Items[1].Text);

ShowMessage(UserForms.AutoTestRandomForm.JewelLB.Items[1]);

 

"Invalid number of parameters of the user form component property."

 

Suggestions?

  • Jerryth's avatar
    Jerryth
    7 years ago

    <apply palm to forehead>

    I know about Items.Items[0] - I was just having a brain fart...

     

    Thanks for getting back in business with a clear concise explanation!

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    It is a bit odd, I know... but try changing the code to 

     

    UserForms.AutoTestRandomeForm.JewalLB.Items.Items[0] := '99';

    ShowMessage(UserForms.AutoTestRandomeForm.JewalLB.Items.Items[0])

     

    The reason being is that the first "Items" is the collection... the second is the array within the collection which actually returns the items.  Also, the "Text" property is not part of that array... you just need to send in the parameter and it will print appropriatly.

     

    Also, note the array is zero based... so, your first item in the list is actually at index 0.

    • Jerryth's avatar
      Jerryth
      Occasional Contributor

      <apply palm to forehead>

      I know about Items.Items[0] - I was just having a brain fart...

       

      Thanks for getting back in business with a clear concise explanation!