Submitted on: 7/4/2016 11:30:15 AM
By: JJ Banks 
Level: Beginner
User Rating: By 1 Users
Compatibility: VB 5.0, VB 6.0
Views: 5385
     Nothing on Newindex in the search. Maybe this will help anybody to have data in two(2) list boxes and want to use.

				Example: The programmer want the user to see a list of file names in the one list, but when an entry is selected, the path to the file, in a hidden list, must open the file in another instance.
It's a good practice to save the path names with the file names into a file at the creation, but afterwards each input have to be split into two list boxes: Line input #1, a$ (the split function can be used here, or, FileN$=Left$(x,x) and PathN$=right$(x,x))
FileN$ go into list1 and PathN$ go to list2.
This is the easiest method so far:
Where L1=List1-sorted and L2=List2-not sorted
dim ak as integer
ak = 0
L1.AddItem "Koos":L1.ItemData(L1.NewIndex) = ak:L2.AddItem "Koospath": ak = ak + 1
L1.AddItem "Andre":L1.ItemData(L1.NewIndex) = ak:L2.AddItem "Andrepath": ak = ak + 1
L1.AddItem "Bets":L1.ItemData(L1.NewIndex) = ak:L2.AddItem "betspath": ak = ak + 1
L2.ListIndex = L1.ItemData(L1.ListIndex)
Label1.Caption = L2.Text
Hope it helps if you search for: Newindex

Other 11 submission(s) by this author


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

7/4/2016 3:27:52 PMdave Carter

NewIndex Property
Returns the index of the item most recently added to a ComboBox or ListBox control.
Read only at run time. (quote from MSDN)
This is really useful especially if the control's Sorted Property is set to True.
Also, note 32,767 item limit to read this property e.g. if reference item 32,768 Overflow error is raised.
(If this comment was disrespectful, please report it.)


Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)

To post feedback, first please login.