- [DEVEXPRESS] Hỗ trợ tìm kiếm highlight không dấu và không khoảng cách trên Gridview Filter
 - [C#] Chia sẻ source code phần mềm Image Downloader tải hàng loạt hình ảnh từ danh sách link url
 - [C#] Chụp hình và quay video từ camera trên winform
 - [C#] Chia sẽ full source code tách file Pdf thành nhiều file với các tùy chọn
 - Giới thiệu về Stock Tracker Widget - Công cụ theo dõi cổ phiếu và cảnh báo giá tăng giảm bằng C# và WPF
 - [VB.NET] Chia sẻ công cụ nhập số tiền tự động định dạng tiền tệ Việt Nam
 - [VB.NET] Hướng dẫn fill dữ liệu từ winform vào Microsoft word
 - [VB.NET] Hướng dẫn chọn nhiều dòng trên Datagridview
 - Hướng Dẫn Đăng Nhập Nhiều Tài Khoản Zalo Trên Máy Tính Cực Kỳ Đơn Giản
 - [C#] Chia sẻ source code phần mềm đếm số trang tập tin file PDF
 - [C#] Cách Sử Dụng DeviceId trong C# Để Tạo Khóa Cho Ứng Dụng
 - [SQLSERVER] Loại bỏ Restricted User trên database MSSQL
 - [C#] Hướng dẫn tạo mã QRcode Style trên winform
 - [C#] Hướng dẫn sử dụng temp mail service api trên winform
 - [C#] Hướng dẫn tạo mã thanh toán VietQR Pay không sử dụng API trên winform
 - [C#] Hướng Dẫn Tạo Windows Service Đơn Giản Bằng Topshelf
 - [C#] Chia sẻ source code đọc dữ liệu từ Google Sheet trên winform
 - [C#] Chia sẻ source code tạo mã QR MOMO đa năng Winform
 - [C#] Chia sẻ source code phần mềm lên lịch tự động chạy ứng dụng Scheduler Task Winform
 - [C#] Hướng dẫn download file từ Minio Server Winform
 
[VB.NET] Kiểm tra hai file text có trùng dữ liệu hay không (Check Difference two file)
Hôm nay, mình xin hướng dẫn các bạn cách so sánh dữ liệu hai file text có giống nội dung với nhau hay không bằng ngôn ngữ lập trình VB.NET.
Tức là, chương trình sẽ kiểm tra dữ liệu 2 file text.
Chương trình mình viết hỗ trợ realtime, nghĩa là khi một trong 2 file dữ liệu thay đổi, thì chương trình của chúng ta sẽ tự động đi kiểm tra.
Nếu 2 file dữ liệu khác nhau, thì chương trình sẽ xuất thông báo cho chúng ta biết dữ liệu bị sai, không trùng nhau.
Chương trình demo:

Source code bằng VB.NET
Imports System.IO
Imports System.Media
Imports System.Threading
Public Class Form1
    Private Function FileCompare(ByVal file1 As String, ByVal file2 As String) As Boolean
        Dim file1byte As Integer
        Dim file2byte As Integer
        Dim fs1 As FileStream
        Dim fs2 As FileStream
        If (file1 = file2) Then
            Return True
        End If
        Thread.Sleep(200)
        fs1 = New FileStream(file1, FileMode.Open)
        fs2 = New FileStream(file2, FileMode.Open)
        If (fs1.Length <> fs2.Length) Then
            fs1.Close()
            fs2.Close()
            Return False
        End If
        Do
            file1byte = fs1.ReadByte()
            file2byte = fs2.ReadByte()
        Loop While ((file1byte = file2byte) And (file1byte <> -1))
        fs1.Close()
        fs2.Close()
        Return ((file1byte - file2byte) = 0)
    End Function
    Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles btnStart.Click
        btnStart.Enabled = False
        btnStop.Enabled = True
        fsw.IncludeSubdirectories = True
        fsw.NotifyFilter = NotifyFilters.FileName Or NotifyFilters.Size
        AddHandler fsw.Changed, AddressOf fsw_changed
        fsw.EnableRaisingEvents = True
    End Sub
    Private Sub fsw_changed(ByVal sender As Object, ByVal e As FileSystemEventArgs)
        'setLabelTxt("Monitoring: " & e.FullPath, Label2)
        Dim result As String
        Dim thoigian As String
        thoigian = System.DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")
        If (FileCompare(txtFile1.Text, txtFile2.Text)) Then
            result = thoigian + " - Tình trạng: OK" + vbNewLine + rtfResult.Text
            setLabelTxt(result, rtfResult)
        Else
            result = thoigian + " - Tình trạng: FAIL" + vbNewLine + rtfResult.Text
            setLabelTxt(result, rtfResult)
            SystemSounds.Beep.Play()
        End If
    End Sub
    Public Shared Sub setLabelTxt(ByVal text As String, ByVal lbl As RichTextBox)
        If lbl.InvokeRequired Then
            lbl.Invoke(New setLabelTxtInvoker(AddressOf setLabelTxt), text, lbl)
        Else
            lbl.Text = text
        End If
    End Sub
    Public Delegate Sub setLabelTxtInvoker(ByVal text As String, ByVal lbl As RichTextBox)
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        If opendialogResult.ShowDialog = DialogResult.OK Then
            Dim path As String = opendialogResult.FileName
            txtFile1.Text = path
        End If
    End Sub
    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        If opendialogResult.ShowDialog = DialogResult.OK Then
            Dim path As String = opendialogResult.FileName
            txtFile2.Text = path
        End If
    End Sub
    Private Sub btnStop_Click(sender As Object, e As EventArgs) Handles btnStop.Click
        btnStart.Enabled = True
        btnStop.Enabled = False
        fsw.EnableRaisingEvents = False
    End Sub
End Class
                                

