Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AddItem Method - Index 1

Status
Not open for further replies.

abds

Programmer
Dec 13, 2000
46
US
I can use List1.AddItem ("string") with no problem.
When I try to pass the position I want "string" to appear at, such as List1.AddItem ("string",index) I get a message from the precompiler saying that I'm missing an = sign.

What is the correct syntax to specify the position?
 
Take off the parens or add CALL in front.
List1.Additem "string",index
Call List1.Additem ("string",index)

You got away with
List1.AddItem ("string")
because putting parens around an argument says evaluate the expression inside and pass the result. VB tried to evaluate ("string",index) and pass the result as a string.
 
The correct syntax is List1.additem "Item 1",Index.
But you cant insert a new item with index greater than the number of items(list1.listcount property)

I would suggest to sort the data before you add them to the listcontrol (within an Array ) and then add them.

Vagelis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top