|
-
Oct 6th, 2000, 04:11 PM
#1
Thread Starter
Addicted Member
very simple listbox thing ...
How can I check if one item is selected in a list box ???
[Edited by pro2 on 10-06-2000 at 05:26 PM]
-
Oct 6th, 2000, 04:25 PM
#2
_______
<?>
If list1.text = "yourtext" then Msgbox "Selected"
If list1.listindex = 1 then Msgbox "ListIndex " list1index selected
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Oct 6th, 2000, 04:25 PM
#3
To check a specific item
Code:
If List1.Selected(5) = True Then
'Item 5 is selected
End If
To see if any item is selected
Code:
For i = 0 To List1.ListCount
If List1.Selected(i) Then 'There is an item selected
Next i
-
Oct 6th, 2000, 04:27 PM
#4
Thread Starter
Addicted Member
is it
For i = 0 To List1.ListCount
If List1.Selected(i) Then 'There is an item selected
Next i
or
For i = 0 To List1.ListCount -1
If List1.Selected(i) Then 'There is an item selected
Next i
??
cause the List count start to 1 and the Index start to 0 ..
-
Oct 6th, 2000, 04:35 PM
#5
_______
<?>
The listindex is zero based
so from 0 to list1.listcount -1
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Oct 6th, 2000, 04:59 PM
#6
Thread Starter
Addicted Member
Ok thank'x a lot..
its workin..
but you forgot the
= True
in the second exemple Megatron ..
-
Oct 6th, 2000, 05:06 PM
#7
_______
<?>
For i = 0 To List1.ListCount
If List1.Selected(i) Then 'There is an item selected
Next i
You don't need the True for it to work
However he did forget the list1.lsitcount -1
and the end if
But I'm sure you figured that out.

Code:
For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then
MsgBox "selected " & List1.ListIndex
'There is an item selected
End If
Next i
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Oct 6th, 2000, 05:49 PM
#8
Hyperactive Member
Re: <?>
Originally posted by HeSaidJoe
However he did forget the list1.lsitcount -1
and the end if
But I'm sure you figured that out.
Actually he didn't leave the End If out... it is not necessary if the Then is
satified on the same line as the IF.
Code:
i = i + 1
If i = 3 then i = 0 'you do not need an End If
PictureBox1.Picture = PictureBox2(i).Picture
[Edited by dsy5 on 10-06-2000 at 06:52 PM]
-
Oct 6th, 2000, 06:04 PM
#9
_______
<?>
dsy5: Thank you for the correction:
What you say it TRUE
Megatron, my humbles apologies...I added a line to your code without realizing I did.
Wayne
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Oct 7th, 2000, 09:20 AM
#10
It should be emphasized that the properties mentioned in HeSaidJoe's original response (Text or ListIndex) are all you need if only one item in the listbox can be selected - i.e., if the MultiSelect property is set to its default of "0 - None". You only need to loop through the items and check the Selected(x) property if you are allowing multi-selection (MultiSelect = Simple or Extended).
"It's cold gin time again ..."
Check out my website here.
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
|