English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2007-03-02 22:15:36 · 2 answers · asked by I don't get it! 1 in Computers & Internet Programming & Design

the argument between the parentheses is invalid for some reason!

2007-03-02 22:56:32 · update #1

2 answers

You can use the remove method
The following code uses a listbox on a form and two buttons. First button resets and loads the listbox.
The second button uses the remove method to remove the selected item from the listbox

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
With Me.ListBox1.Items
.Clear()
.Add("first")
.Add("second")
.Add("Third")
.Add("fourth")
End With
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim idx As Integer

idx = Me.ListBox1.SelectedIndex
If idx > -1 Then
Me.ListBox1.Items.Remove(Me.ListBox1.Items.Item(idx))

Else
MessageBox.Show("No item is selected")
End If


End Sub

2007-03-03 06:32:01 · answer #1 · answered by MarkG 7 · 0 0

Hi there.

Usually holding down the CTRL key and clicking on the unwanted selected item will deselect it within a listbox.

Note that CTRL key acts as a toggle key .. either selecting or unselecting that list item.

Now if you wanted to totally remove that item OFF the list, you'll have to create a special command button that does that job.

Here's some examples:

ComboBox1.Items.Remove(ComboBox1.SelectedItem)
ListBox1.Items.Remove(ListBox1.SelectedItem)

Hope this helps

PS. if you see the line is kinda cut off with ..., just move your mouse pointer over the line and it'll come up as a tooltip.

2007-03-03 06:18:46 · answer #2 · answered by iskai 4 · 0 0

fedest.com, questions and answers