Add, Remove and Clear Items from ListView Control in VB.NET

Private Sub cmdAddItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddItem.Click
      lvItemList.Items.Add(txtAddItem.Text & “”)
End Sub
 

Private Sub cmdRemoveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRemoveItem.Click
 For Each lvItem As ListViewItem In lvItemList.SelectedItems
      lvItem.Remove()
 Next
End Sub

Private Sub cmdClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClear.Click
      lvItemList.Items.Clear()
End Sub

Scripting.FileSystemObject in ASP.NET 4.0

If you have some old VB code to insert into your new ASP.NET 4 project, and there is “Scripting.FileSystemObject” in your code, maybe you can not compiled it because you will get the error message :

‘Scripting.FileSystemObject’ can not found.

The solution is Add Reference to an old COM object, the COM object name is Microsoft.Scripting.Runtime. Please see below image, you must know how to add the reference followed the image showing: