05-08-2011, 02:24 PM
05-08-2011, 03:16 PM
Good share PURP, it should help some people out.
05-09-2011, 12:57 PM
Nice share PURP! ;)
05-09-2011, 01:12 PM
05-12-2011, 10:46 AM
Since the code is in image, and cannot be copy and pasted. I post for copy and paste purposes. A bit slight change in codings but same output as the TS.
Full codes:
Full codes:
Code:
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
'This opens a .txt to the listbox
Try
Using asd As New OpenFileDialog() With {.Filter = ("Text Files|*.txt")}
asd.ShowDialog()
Using streamread As New IO.StreamReader(asd.FileName)
While (streamread.Peek() > -1)
ListBox1.Items.Add(streamread.ReadLine)
End While
End Using
End Using
Catch ex As Exception
End Try
Label1.Text = ListBox1.Items.Count
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
'This removes all duplicates from a listbox
Dim i, j As Integer
Dim arr As New ArrayList
Dim itemfound As Boolean
For i = 0 To ListBox1.Items.Count - 1
itemfound = False
For j = 0 To i - 1
If ListBox1.Items.Item(i) = ListBox1.Items.Item(j) Then
itemfound = True
Exit For
End If
Next j
If Not itemfound Then
arr.Add(ListBox1.Items.Item(i))
End If
Next i
ListBox1.Items.Clear()
ListBox1.Items.AddRange(arr.ToArray)
arr = Nothing
Label1.Text = ListBox1.Items.Count
End Sub
End Class
05-12-2011, 11:30 AM
(05-12-2011, 10:46 AM)euverve Wrote: [ -> ]Since the code is in image, and cannot be copy and pasted. I post for copy and paste purposes. A bit slight change in codings but same output as the TS.
Full codes:
Code:Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
'This opens a .txt to the listbox
Try
Using asd As New OpenFileDialog() With {.Filter = ("Text Files|*.txt")}
asd.ShowDialog()
Using streamread As New IO.StreamReader(asd.FileName)
While (streamread.Peek() > -1)
ListBox1.Items.Add(streamread.ReadLine)
End While
End Using
End Using
Catch ex As Exception
End Try
Label1.Text = ListBox1.Items.Count
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
'This removes all duplicates from a listbox
Dim i, j As Integer
Dim arr As New ArrayList
Dim itemfound As Boolean
For i = 0 To ListBox1.Items.Count - 1
itemfound = False
For j = 0 To i - 1
If ListBox1.Items.Item(i) = ListBox1.Items.Item(j) Then
itemfound = True
Exit For
End If
Next j
If Not itemfound Then
arr.Add(ListBox1.Items.Item(i))
End If
Next i
ListBox1.Items.Clear()
ListBox1.Items.AddRange(arr.ToArray)
arr = Nothing
Label1.Text = ListBox1.Items.Count
End Sub
End Class
He probably didn't want people to copy & paste...