# match string 2 • ### Question

• Hi All,

sorry re-post back pevious question.Just for learning vb and very sorry about uncomfortable.

Hope somebody correct this code.

I try explain again what I try to do

1. List A_("768")

Make combination in first line "786,687,678,876,867"
2. List A_("836")

Make combination in second line "863,368,386,683,638"

3. List B_.Having 3 digit

First line B_ ;

"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,"

second line B_ ;

"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,"

4.I want to find all combination in first line List A_in first line List B_ and then find all combination in second line List A_in second line List B_

5. Output in textbox4 is

768=0
786=0
687=0
678=0
876=0
867=0

result first line=0

836=0
863=0
368=0
386=1
683=0
638=1
result first line=2
```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)
Dim D_ As New List(Of String)

Dim A1_ As New List(Of String)
Dim B1_ As New List(Of String)
Dim C1_ As New List(Of String)

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

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

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
Me.TextBox3.AppendText(StringsToFind(J) & vbCrLf)
Dim Count As Integer = 0
For Each Check As String In B_
If Check.Contains(StringsToFind(J)) Then Count += 1
Next
TextBox4.AppendText(StringsToFind(J) & "=" & Count & vbCrLf)
Next
TextBox4.AppendText(vbCrLf)

Next
Next

End Sub

End Class
```

Saturday, March 14, 2020 12:04 AM

• For first line in List_A ONLY first line in List B_

For second line in List_A ONLY second  line in List B_

If you only want to check Line 1 of A_ against Line 1 of B_, and Line 2 of A_
against Line 2 of B_, why are you iterating over ALL lines of B_ for EACH
line in A_? Wouldn't it make more sense to use the same index for BOTH A_
and B_?

```    For J As Integer = 0 To StringsToFind.Count - 1
Me.TextBox3.AppendText(StringsToFind(J) & vbCrLf)
Dim Count As Integer = 0

'For Each Check As String In B_
'    If Check.Contains(StringsToFind(J)) Then Count += 1
'Next

If B_(I).Contains(StringsToFind(J)) Then Count += 1 ' ***

TextBox4.AppendText(StringsToFind(J) & "=" & Count & vbCrLf)
Next
```

- Wayne

• Marked as answer by Saturday, March 14, 2020 6:06 AM
Saturday, March 14, 2020 5:36 AM

### All replies

• sorry re-post back pevious question.Just for learning vb and very sorry about uncomfortable.

Hope somebody correct this code.

I try explain again what I try to do

1. List A_("768")

Make combination in first line "786,687,678,876,867"
2. List A_("836")

Make combination in second line "863,368,386,683,638"

3. List B_.Having 3 digit

First line B_ ;

"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,"

second line B_ ;

"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,"

4.I want to find all combination in first line List A_in first line List B_ and then find all combination in second line List A_in second line List B_

768=0
786=0
687=0
678=0
876=0
867=0

result first line=0

836=0
863=0
368=0
386=1
683=0
638=1
result first line=2

Do NOT start a new thread when you already have a thread open for the same issue.

One reason you aren't getting replies is because there are still contradictions

You have said that you want to make all combinations from the 1st AND 2nd lines
of A_

1. List A_("768")

Make combination in first line "786,687,678,876,867"
2. List A_("836")

Make combination in second line "863,368,386,683,638"

THEN you say:

"4.I want to find all combination in first line List A_in first line List B_
and then find all combination in second line List A_in second line List B_"

Do you not see how you are contradicting yourself?

First you want to COMBINE the combinations from lines 1 AND 2 in A_.

But then you say you want to find the combinations of LINE 1 from A_
that are in LINE 1 of B_, and then find the combinations of LINE 2 from A_
that are in LINE 2 of B_. In other words your description says you DON'T want
to apply the combinations form LINE 1 of A_ to LINE 2 of B_, and you DON'T
want to apply the combinations from LINE 2 of A_ to LINE 1 of B_.

result first line=0

result first line=2

That suggests that you ARE applying BOTH patterns (lines) from A_ to at
least the FIRST line of B_.

Make up your mind and give a CLEAR and CONSISTENT description of what you
are trying to do, as well as correct EXAMPLES of the expected input and output.
Then you will get a code solution rather promptly.

Perhaps the reason you haven't been able to code this rather simple exercise
yourself - after MANY months of doing similar coding - is because there are

- Wayne

Saturday, March 14, 2020 12:58 AM
• sorry Wayne,maybe my explanation very bad.

Maybe a simple word to said.

For first line in List_A ONLY first line in List B_

For second line in List_A ONLY second  line in List B_

thank.

• Edited by Saturday, March 14, 2020 3:23 AM add
Saturday, March 14, 2020 3:20 AM
• For first line in List_A ONLY first line in List B_

For second line in List_A ONLY second  line in List B_

If you only want to check Line 1 of A_ against Line 1 of B_, and Line 2 of A_
against Line 2 of B_, why are you iterating over ALL lines of B_ for EACH
line in A_? Wouldn't it make more sense to use the same index for BOTH A_
and B_?

```    For J As Integer = 0 To StringsToFind.Count - 1
Me.TextBox3.AppendText(StringsToFind(J) & vbCrLf)
Dim Count As Integer = 0

'For Each Check As String In B_
'    If Check.Contains(StringsToFind(J)) Then Count += 1
'Next

If B_(I).Contains(StringsToFind(J)) Then Count += 1 ' ***

TextBox4.AppendText(StringsToFind(J) & "=" & Count & vbCrLf)
Next
```

- Wayne

• Marked as answer by Saturday, March 14, 2020 6:06 AM
Saturday, March 14, 2020 5:36 AM
• Thank you very much Wayne,

I need ths code,it's correct.

sorry Wayne.

Saturday, March 14, 2020 6:06 AM