Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Stop duplicates while loading list into listview
Author:
RattleSnake
Submitted:
12/8/2005
Version:
VB6
Compatibility:
VB6
Category:
String Manipulation
Views:
16455
This Code demonstrates how to use a Common Dialog and load a txt file into Listview and remove Duplicates from it while loading.
Declarations:
'By Rattlesnake 'Add the following components: 'Common Dialoag Control 'Microsoft Windows Common Components 'add a command button to your form 'add a listview to your form 'rename common dialog1 to CD1 'If you want the list to be sorted alphabetically try this 'change to the following properties on listview1 'Arrange=lvwAutoTop 'SortOrder=lvwAscending 'View=lvwSmallIcon
Code:
Private sub Command1_Click() On Error GoTo ErrorHandler Dim Lsttext As String CD1.DialogTitle = "Load List" CD1.InitDir = App.Path CD1.Flags = &H4 CD1.Filter = "Text files (*.txt)|*.txt|all files or custom(*.*)|*.*" CD1.ShowOpen If CD1.FileName = "" Then GoTo ErrorHandler ListView1.ListItems.Clear Open CD1.FileName For Input As #1 While Not EOF(1) Input #1, Lsttext If ListView1.FindItem(Lsttext) Is Nothing Then ListView1.ListItems.Add , , Lsttext Wend Close #1 ErrorHandler: Exit Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement