3 Replies - 776 Views - Last Post: 02 December 2009 - 10:22 AM Rate Topic: -----

#1 imjuicedbigtyme  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-December 09

Friends Solution diff ? than steph

Posted 01 December 2009 - 10:13 PM

I am on the same case problem as stephanie's post but I have a different question. The book says,

The Remove button should remove (From the list portion of the combo box) the name either entered in the text portion or selected in the list portion. (hint: use the items collection's remove method.)

Posted Image

i can select the item and remove it manually, but i cant get it to remove with i just have the name in the text portion.

	Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click

		If cboFriends.SelectedIndex <> -1 Then
			cboFriends.Items.RemoveAt(cboFriends.SelectedIndex)
		End If


	End Sub


Is This A Good Question/Topic? 0
  • +

Replies To: Friends Solution diff ? than steph

#2 Sethro117  Icon User is offline

  • Still the sexiest mofo.
  • member icon

Reputation: 236
  • View blog
  • Posts: 2,378
  • Joined: 14-January 09

Re: Friends Solution diff ? than steph

Posted 01 December 2009 - 10:46 PM

You need to use Remove instead of RemoveAt. RemoveAt uses integer based removal like Item(0), Item(1) etc. Remove can do text. So try:
   ListBox1.Items.Remove(TextBox1.Text)


Was This Post Helpful? 0
  • +
  • -

#3 mark.bottomley  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 176
  • View blog
  • Posts: 990
  • Joined: 22-April 09

Re: Friends Solution diff ? than steph

Posted 02 December 2009 - 08:17 AM

ComboBox.FindStringExact - this will return the index of an exact match in the combobox, or -1 if not found. Use you input box as the search criteria. Note that you should try to keep the case matched for a reliable compare - either all upper case or lower case.
Was This Post Helpful? 0
  • +
  • -

#4 imjuicedbigtyme  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-December 09

Re: Friends Solution diff ? than steph

Posted 02 December 2009 - 10:22 AM

Thanks sethro, I thought the teacher was looking for something else. What I had was correct.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1