Repeated row filtering tool (. NET source code + tool)

Source: Internet
Author: User

Duplicate row filtering tool (vs2010.NET source code + tool) is poorly written: (use together :)
Today, I wrote a tool for filtering repeated text in the project. It is estimated that this tool will be used in the future. I will share it here to give you a poor level of programming .. Sorry
Imports System. IO
Imports System. Threading
Public Class Main
Public DoMainAddress As ArrayList = New ArrayList
Public FilePath As String
Private Sub button#click (sender As System. Object, e As System. EventArgs) Handles Button1.Click
If Button1.Text = "select file" Then
If RichTextBox1.Text <> "" Then
RichTextBox1.Text = ""
End If
OpenFileDialog1.Multiselect = True
OpenFileDialog1.Filter = "all files | *.*"
OpenFileDialog1.FileName = ""
OpenFileDialog1.ShowDialog ()
FilePath = OpenFileDialog1.FileName
If OpenFileDialog1.FileName <> "" Then
Dim RunThread As Thread = New Thread (New ThreadStart (AddressOf ReadFile ))
RunThread. Start ()
Button1.Text = "executed"
End If
Else
RichTextBox1.Text = ""
Dim RunThread As Thread = New Thread (New ThreadStart (AddressOf ReadFileRun ))
RunThread. Start ()
Button1.Text = "select file"
End If
End Sub
Public Sub ReadFileRun ()
Dim sr As System. IO. StreamReader = New StreamReader (FilePath, System. Text. Encoding. Default, True)
Do While sr. Peek>-1
Dim Tempsr As String = sr. ReadLine & vbCrLf
If DoMainAddress. Contains (Tempsr) = False Then
DoMainAddress. Add (Tempsr)
End If
Loop
Sr. Close ()
Dim wrstr As String = ""
For I As Integer = 0 To DoMainAddress. Count-1
Wrstr & = DoMainAddress (I). ToString
RichTextBox1.AppendText (I & "" & DoMainAddress (I). ToString)
Next
Dim FileName1 As String = "\ Done.txt"
If File. Exists (Application. StartupPath & "\ Done.txt") = True Then
If MsgBox ("Path:" & Application. StartupPath & FileName1 & "Overwrite existing file?", MsgBoxStyle. YesNo Xor MsgBoxStyle. Information) = MsgBoxResult. Yes Then
FileName1 = "\ Done.txt"
Else
FileName1 = "\ filtered [" & OpenFileDialog1.SafeFileName & "cmd.txt"
End If
End If
Dim wr As StreamWriter = New StreamWriter (Application. StartupPath & FileName1)
Wr. Write (wrstr)
Wr. Close ()
MsgBox ("execution completed" & vbCrLf & "file generation path:" & Application. StartupPath & FileName1, MsgBoxStyle. Information)
End Sub
Public Sub ReadFile ()
Dim sr As System. IO. StreamReader = New StreamReader (FilePath, System. Text. Encoding. Default, True)
Do While sr. Peek>-1
RichTextBox1.AppendText (sr. ReadLine & vbCrLf)
Loop
End Sub
Private Sub Form1_Load (sender As Object, e As System. EventArgs) Handles Me. Load
Checkforillegalcrossthreadcils = False
End Sub
Private Sub usage instructions ToolStripMenuItem_Click (sender As System. Object, e As System. EventArgs) Handles usage instructions ToolStripMenuItem. Click
MsgBox ("1. read and compare by row "& vbCrLf &" 2. press <Select File> and then <Select File> to <execute> click <execute> to generate a done.txt file in the program directory. txt ", 48," By: MythHack ")
End Sub
Private Sub about ToolStripMenuItem_Click (sender As System. Object, e As System. EventArgs) Handles about ToolStripMenuItem. Click
MsgBox ("By: MythHack" & vbCrLf & "www.MythHack.com" & vbCrLf & "2012-05-22", MsgBoxStyle. Information)
End Sub
End Class

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.