Match a strings

  • Thread starter Thread starter mipakteh
  • Start date Start date
M

mipakteh

Guest
Hi All,

Test to find a list A_ in list B_.

The another way succed with Leshay code but I want try for this way.

Somebody can fix for this code.

Option Strict On
Option Explicit On

Imports System.IO
Imports System.Data
Imports System.Text

Public Class Form1

Dim A_ As New List(Of String)
Dim B_ As New List(Of String)
Dim C_ As New List(Of String)


Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

A_.Add("768")
A_.Add("836")

For I As Integer = 0 To A_.Count - 1
TextBox1.AppendText(A_(I) & vbCrLf)
Next

B_.Add("613,613,633,133,305,300,350,050,654,653,643,543,161,166,116,616,392,393,323,923,834,835,845,345,201,542,")
B_.Add("635,638,658,358,142,142,122,422,694,696,646,946,429,427,497,297,824,822,078,242,543,547,201,437,386,411,")

For I As Integer = 0 To B_.Count - 1
TextBox2.AppendText(B_(I) & vbCrLf)
Next


End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim sb As New StringBuilder

For I As Integer = 0 To A_.Count - 1

Dim StringToCheck As String = A_(I).ToString
Dim StringsToCheck As String() = StringToCheck.Split(","c)

For Each S As String In StringsToCheck

'0 1 2
'0 2 1
'1 2 0
'1 0 2
'2 0 1
'2 1 0

Dim StringsToFind As String() = {S(0) & S(1) & S(2),
S(0) & S(2) & S(1),
S(1) & S(2) & S(0),
S(1) & S(0) & S(2),
S(2) & S(0) & S(1),
S(2) & S(1) & S(0)}

For J As Integer = 0 To StringsToFind.Count - 1
sb.Append(StringsToFind(J) & vbCrLf)
C_.Add(StringsToFind(J))
Next
Next
Next
Me.TextBox3.AppendText(sb.ToString)


For I As Integer = 0 To B_.Count - 1
Dim StrToCheck() As String = B_(I).Split(","c)
Dim Count As Integer = 0
For j As Integer = 0 To C_.Count - 1
For Each Check As String In StrToCheck
If Check.Contains(C_(j)) Then Count += 1
Next
Next
TextBox4.AppendText("Occurances (" & A_(I) & ")= " & Count.ToString & vbCrLf)
Next

End Sub
End Class



The error occur when we put the 678 in line2 in list B_

1553190.png

Continue reading...
 

Similar threads

Back
Top