|
-
Mar 20th, 2003, 05:13 PM
#1
Thread Starter
Hyperactive Member
getting the index of items in a listbox
i go through the listbox using
dim x as integer
dim intIndex as integer
for x = 0 to listbox.listcount
intindex = listbox.list(x).index
next x
i recieve an error..
i want to get the index of all the items in the listbox and put that in a variable as it goes throught the list... any ideas?
-
Mar 20th, 2003, 05:19 PM
#2
PowerPoster
Well
Get the index? Please explain more...
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Mar 20th, 2003, 05:22 PM
#3
Thread Starter
Hyperactive Member
reply..
lets say i have 7 items in the listbox..
as i loop through the listbox i am putting those 7 items into a file and i want along with that to put the associating index...
strData & intIndex
so the output would look like
"MyData","4"
so that I know the placement of that data in the listbox by the index.
- gabe
-
Mar 20th, 2003, 05:24 PM
#4
PowerPoster
Well
Just add in the x counter ?
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Mar 20th, 2003, 05:45 PM
#5
Thread Starter
Hyperactive Member
yup
thats what i tried but i get an error...
For x = 0 To lstAlertLevels.ListCount
intIndex = lstAlertLevels.List(x).Index
Debug.Print lstAlertLevels(x).ListIndex
Next x
-
Mar 20th, 2003, 05:47 PM
#6
Addicted Member
For x = 0 To lstAlertLevels.ListCount -1
intIndex = lstAlertLevels.List(x).Index
Debug.Print lstAlertLevels(x).ListIndex
Next x
the highest index is listcount -1, since the 0 index is counted too.
Hope it helps
-
Mar 20th, 2003, 05:47 PM
#7
Fanatic Member
Try this code, if your base is 0 then it can't go to ListCount because that be 1 more than existing.
VB Code:
dim x as integer
dim intIndex as integer
for x = 0 to listbox.listcount -1
intindex = listbox.list(x).index
next x
(I love when I submit the same advice as someone else)
-
Mar 20th, 2003, 05:48 PM
#8
Frenzied Member
People, there is no such thing as lstAlertLevels.List(x).Index
James ment:
Code:
For x = 0 To lstAlertLevels.ListCount -1
Debug.Print lstAlertLevels(x).ListIndex & "," & x
Next x
-
Mar 20th, 2003, 05:55 PM
#9
Thread Starter
Hyperactive Member
error
i recieve an error here...
wrong number of arguments or invalid property assignment
For x = 0 To lstAlertLevels.ListCount - 1
Debug.Print lstAlertLevels(x).ListIndex & "," & x
Next x
lstAlertLevels is highlighted right after the debug.print...
-
Mar 20th, 2003, 05:56 PM
#10
PowerPoster
wELL
VB Code:
For x = 0 To lstAlertLevels.ListCount - 1
Debug.Print lstAlertLevels(x).lList & "," & x
Next x
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Mar 20th, 2003, 05:58 PM
#11
Frenzied Member
Re: error
Originally posted by gmatteson
i recieve an error here...
wrong number of arguments or invalid property assignment
For x = 0 To lstAlertLevels.ListCount - 1
Debug.Print lstAlertLevels(x).ListIndex & "," & x
Next x
lstAlertLevels is highlighted right after the debug.print...
Sorry, didn't see that
Try:
Code:
For x = 0 To lstAlertLevels.ListCount - 1
Debug.Print lstAlertLevels.List(x) & "," & x
Next x
-
Mar 20th, 2003, 06:01 PM
#12
Thread Starter
Hyperactive Member
haha
i feel ashamed, too tired lol....
-
Mar 20th, 2003, 06:46 PM
#13
PowerPoster
This code is correct.
VB Code:
For x = 0 To lstAlertLevels.ListCount - 1
Debug.Print lstAlertLevels.List(x) & "," & x
Next x
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|