 |
 |
|

11-09-2003, 07:37 PM
|
|
Freshman
|
|
Join Date: Nov 2003
Posts: 28
|
|
Removing listbox selected item
|
How do I remove a user selected item in a listbox. Right now I have....
Code:
Private Sub Command3_Click()
lbo(RemoveItem) = lbo(SelectedItem)
End Sub
Where "lbo" is the name of the listbox. But that just yields a command button that does nothing at all.
I have anoter selected item that works similar (which works), where it gets the selected item in the listbox and sends it to the web browser
Code:
Private Sub Command1_Click()
Denlou.WebBrowser1.Navigate lbo(SelectedItem)
Unload favorites
End Sub
And I can't remove the equals sign because it returns "Expected: End of Statement"
Anyone know what to do?
|
|

11-09-2003, 07:40 PM
|
 |
Keeper of foo
Retired Moderator * Guru *
|
|
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
|
|
|
lbo.RemoveItem lbo.ListIndex
|
__________________
~ Quod non mortiferum, fortiorem me facit ~
Avatar by lebb
|

11-09-2003, 07:41 PM
|
 |
Senior Contributor
|
|
Join Date: Aug 2003
Location: Tomarria
Posts: 905
|
|
Remove the current .listindex
Code:
lblWhatever.RemoveItem lblWhatever.ListIndex
|
__________________
...leben ohne sinn...
|

11-09-2003, 07:41 PM
|
 |
Senior Contributor
|
|
Join Date: Oct 2003
Location: Chattanooga, TN USA
Posts: 1,069
|
|
Code:
lbo.RemoveItem lbo.ListIndex
geeze got beat my 2 ppl!
|
|

11-09-2003, 07:45 PM
|
|
Freshman
|
|
Join Date: Nov 2003
Posts: 28
|
|
|
"Method or Data Member Not found" Then it highlights ".ListIndex"
|
__________________
-Ryan L
"Noob in training"
|

11-09-2003, 07:47 PM
|
 |
Senior Contributor
|
|
Join Date: Oct 2003
Location: Chattanooga, TN USA
Posts: 1,069
|
|
|
what language are you using?
.Net?
|
|

11-09-2003, 07:49 PM
|
 |
Senior Contributor
|
|
Join Date: Aug 2003
Location: Tomarria
Posts: 905
|
|
If there is nothing selected, you will get an error. To check if there is something selected, do this:
Code:
If someList.ListIndex = -1 then
'there is nothing selected
end if
|
__________________
...leben ohne sinn...
|

11-09-2003, 07:52 PM
|
|
Freshman
|
|
Join Date: Nov 2003
Posts: 28
|
|
|
There was something selected and I'm using VB6.
|
__________________
-Ryan L
"Noob in training"
|

11-09-2003, 07:52 PM
|
 |
Senior Contributor
|
|
Join Date: Oct 2003
Location: Chattanooga, TN USA
Posts: 1,069
|
|
|
If nothing is selected you get an invalid procedure call, not method or data member not found. He isn't using vb6.0
|
|

11-09-2003, 07:53 PM
|
 |
Keeper of foo
Retired Moderator * Guru *
|
|
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
|
|
__________________
~ Quod non mortiferum, fortiorem me facit ~
Avatar by lebb
|

11-09-2003, 07:53 PM
|
 |
Senior Contributor
|
|
Join Date: Oct 2003
Location: Chattanooga, TN USA
Posts: 1,069
|
|
|
Then what kind of listbox are you using?
Because ListIndex is a method of the Listbox control.
|
|

11-09-2003, 07:54 PM
|
 |
Senior Contributor
|
|
Join Date: Aug 2003
Location: Tomarria
Posts: 905
|
|
|
Maybe your control name was lstABC and you said lstACB (of course not those names). Typos cause lots of probs in programming.
|
__________________
...leben ohne sinn...
|

11-09-2003, 07:55 PM
|
|
Freshman
|
|
Join Date: Nov 2003
Posts: 28
|
|
Revised Code....
Code:
Private Sub Command3_Click()
lbo.RemoveItem lbo.ListIndex
End Sub
....And it's VB6.0
|
__________________
-Ryan L
"Noob in training"
|

11-09-2003, 07:55 PM
|
 |
Senior Contributor
|
|
Join Date: Oct 2003
Location: Chattanooga, TN USA
Posts: 1,069
|
|
|
Then he would've got an object required error. Make sure you spelled ListIndex correctly.....
|
|

11-09-2003, 07:56 PM
|
 |
Keeper of foo
Retired Moderator * Guru *
|
|
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
|
|
|
Are you using Option Explicit?
|
__________________
~ Quod non mortiferum, fortiorem me facit ~
Avatar by lebb
|

11-09-2003, 07:57 PM
|
|
Freshman
|
|
Join Date: Nov 2003
Posts: 28
|
|
Quote: Originally Posted by reboot Are you using Option Explicit?
No, should I?
|
__________________
-Ryan L
"Noob in training"
|

11-09-2003, 07:58 PM
|
 |
Senior Contributor
|
|
Join Date: Oct 2003
Location: Chattanooga, TN USA
Posts: 1,069
|
|
This works for me.....
Code:
Option Explicit ' works perfectly without this also....
Private Sub Command1_Click()
lbo.RemoveItem lbo.ListIndex
End Sub
Private Sub Form_Load()
lbo.AddItem "item1"
lbo.AddItem "item1"
lbo.AddItem "item1"
End Sub
|
|

11-09-2003, 07:59 PM
|
|
Freshman
|
|
Join Date: Nov 2003
Posts: 28
|
|
|
Tried what you said, but it still comes up with the same error.
|
__________________
-Ryan L
"Noob in training"
|

11-09-2003, 08:01 PM
|
 |
Senior Contributor
|
|
Join Date: Oct 2003
Location: Chattanooga, TN USA
Posts: 1,069
|
|
|
What kind of listbox are you using then?
|
|

11-09-2003, 08:02 PM
|
 |
Senior Contributor
* Expert *
|
|
Join Date: May 2002
Location: Vancouver, USA
Posts: 999
|
|
Quote: Originally Posted by knight
Quote: Originally Posted by reboot Are you using Option Explicit?
No, should I?
The answer would be...ALWAYS!

|
__________________
1011 0000 1011
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|