elianeasmar
Well-known member
- Joined
- Oct 3, 2013
- Messages
- 76
- Programming Experience
- Beginner
Hello.
I need your help guys. i need to remove an item from a collection. And i know that
I can't delete an item or an object from a collection. But i can add the object that i want to delete/remove to another collection.
But i'm a bit week in coding. so can anyone help me please?
Thank you
I appreciate any help
this is my code that i wrote so far:
I need your help guys. i need to remove an item from a collection. And i know that
I can't delete an item or an object from a collection. But i can add the object that i want to delete/remove to another collection.
But i'm a bit week in coding. so can anyone help me please?
Thank you
I appreciate any help
this is my code that i wrote so far:
Public Class Form1 Dim _collection As Collection Dim _icollection As IList(Of _schoolinfo) Private index As Int16 = 0 Dim _inf As New _schoolinfo Dim _infoschool As String Dim _info As _schoolinfo Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load _icollection = New List(Of _schoolinfo) _collection = New Collection RefreshControls("N") PrepareTextBox(False) Me.txtWelcome.Text = pbuserName ' _loginForm.Hide() Me.btnNew.Focus() End Sub Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click _info = New _schoolinfo With _info .Code = txtCode.Text .Name = txtName.Text .PhoneNumber = txtPhoneNumber.Text .Address = txtAddress.Text .Title = cmbTitle.Text .Position = cmbPosition.Text .DateTime = txtDate.Text If RDFemale.Checked Then .Sex = "Female" If RDMale.Checked Then .Sex = "Male" End If End If End With If _infoschool = "I" Then index = _collection.Count + 1 _icollection.Add(New _schoolinfo With {.Code = txtCode.Text, .Name = txtName.Text, .PhoneNumber = txtPhoneNumber.Text, .Address = txtAddress.Text, .Title = cmbTitle.Text, .Position = cmbPosition.Text, .DateTime = txtDate.Text}) _collection.Add(_info, getkey(index)) Else '_info = New _schoolinfo If _collection Is Nothing Then _collection = New Collection If _collection.Count > 0 Then _collection.Remove(getkey(index)) _collection.Add(_info, getkey(index)) End If _inf = Nothing PrepareTextBox(False) RefreshControls("L") End Sub Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click '---------------------------------------------------------------- End Sub
Last edited by a moderator: