Visual Basic Online Course - ListView, Element not found while removing items
Visual Basic Online Course
ListView, Element not found while removing items
In VB6 If you tried to remove items from ListView Control, you may get this error :
Run-Time Error '35601':Element not found.
Example :
Code :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'Visual Basic 6.0 | |
'Solution for ListView Control | |
Option Explicit | |
Dim i As Integer | |
Private Sub Form_Load() | |
For i = 1 To 10 | |
ListView1.ListItems.Add Key:="lv_" & i, Text:="ListItem #" & i | |
Next | |
End Sub | |
Private Sub Command1_Click() | |
For i = 1 To ListView1.ListItems.Count | |
If ListView1.ListItems("lv_" & i).Selected Then | |
ListView1.ListItems.Remove i | |
End If | |
Next | |
End Sub |
Error :
Executing the previous example will cause error '35601' when trying to remove the next Item from list view items.
Solution :
Simple error trap will fix the error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'Visual Basic 6.0 | |
'solutions for ListView control | |
On Error Resume Next | |
For i = 1 To ListView1.ListItems.Count | |
If Listiew1.ListItems("lv_" & i).Selected Then | |
ListView1.ListItems.Remove i | |
End If | |
Next |
♥ Visual Basic 6.0 Course Online :
- Automate MS-Access Database in Visual Basic 6.0 though a network
- Visual Basic 6.0 Analog Clock
- Visual Basic 6.0 Temperature Convertor
- Visual Basic 6.0, MS-Access 2003 and Crystal Reports - Phone book
- Visual Basic 6.0, MS-Access 2003 Database and DataGridView
- Visual Basic 6.0 FTP full application source code
- Visual Basic 6.0 Color Picker tool source code
- Visual Basic 6.0 TreeView Control lesson (Part1 - Part 2 - Part3 - Part4 - Part5) Arabic.
- Visual Basic 6.0 - Introduction to Graphics (Part1 - Part2 - Part3)
- Visual Basic 6.0 and MS-Excel 2003 tutorials (Part1 - Part2 - Part3 - Part4 - Part5 - Part6)
Comments
Post a Comment
visual basic 6 source code says (Hi)