Created
December 15, 2013 19:52
-
-
Save facebookegypt/7977299 to your computer and use it in GitHub Desktop.
VB 2010 Compare Two Treeviews and return the differences result
This file contains hidden or 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 Online Course - Arrays | |
'http://www.evry1.net/VBNet/ | |
'Compare Two Arrays and Return differences - Dec./2013 | |
'By/ evry1falls [Google me] | |
Public Class Form1 | |
Private Sub Form1_Load(sender As System.Object, _ | |
e As System.EventArgs) Handles MyBase.Load | |
'Nothing to be done here | |
End Sub | |
Private Sub BtnDiff_Click(sender As System.Object, _ | |
e As System.EventArgs) Handles BtnDiff.Click | |
Dim Nodes1Cnt As Integer = TRV1.Nodes.Count - 1 | |
Dim Nodes2Cnt As Integer = TRV2.Nodes.Count - 1 | |
'TextBoxes are used | |
Dim Txt1, Txt2 As New TextBox | |
For I As Integer = 0 To Nodes1Cnt | |
Txt1.AppendText(TRV1.Nodes(I).Text & (vbCrLf)) | |
Next | |
For I As Integer = 0 To Nodes2Cnt | |
Txt2.AppendText(TRV2.Nodes(I).Text & (vbCrLf)) | |
Next | |
Dim Sfound As String = "" | |
Dim XI As Integer = 0 | |
Dim Lines1 = Txt1.Lines | |
Dim Lines2 = Txt2.Lines | |
For Each line In Lines1 | |
Dim curLine As String = line | |
If Lines2.Any(Function(s) s.Equals(curLine, _ | |
StringComparison.CurrentCultureIgnoreCase)) Then | |
Dim Matched As String = (curLine & vbCrLf) | |
'You can retrieve matches here, | |
' I.E [TextBox2.Text = Matched] | |
Else | |
'Return Array comparison result here | |
Sfound += (curLine & vbCrLf) | |
End If | |
Next | |
TxtDiff.Text = Sfound | |
End Sub | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment