Combine 2digit and 0 to 9

• Question

• Hi All,

I have a digits lines in text file;

0505,5793,3905,5814,1883,9785,0944,5367,0622,4236,9690,5981,3717,2191,6083,0617,1808,0070,5181,3228,7846,5730,5790
0791,9484,5920,4333,4214,7636,9124,1229,0376,9545,5727,8592,5846,7744,5821,5364,5666,7129,6225,5376,1521,7283,5044

and then I count 2 digit macthing every digits put into Textbox2.

The Button_3 to remove the same digit Example ;99, 44 ....

The Button_4 to select a maxima count match.

The Button_5 to combine maxima Digit and 0 to 9. then count again .

I need TextBox6 show if count 590 = 3 not show

590 = 1

590 = 2

590 = 3

Somebody can show code for me.

Thank.

```Option Strict On
Option Explicit On
Option Infer Off

Imports System.IO
Imports System.Data

Public Class Form2
Dim List_1 As New List(Of Integer)
Dim List_2 As New List(Of Integer)

Dim ListFound_ As New List(Of Integer)
Dim ListCount_ As New List(Of Integer)

Private ListFoundMax As New List(Of Integer)
Private ListFoundOther As New List(Of Integer)
Private ListFoundStrings As New List(Of Integer)

Private ListDigits As New List(Of Integer)
Private Checking_S As New List(Of Integer)```

```   Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click

Do While sr.Peek <> -1

Dim StringToCheck As String = sr.ReadToEnd

StringToCheck = StringToCheck.Replace(vbCrLf, ",")
StringToCheck = StringToCheck.TrimEnd(CChar(","))

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

For Each S As String In StringsToCheck
Dim StringsToFind As String() = {S(0) & S(1), _
S(0) & S(2), _
S(0) & S(3), _
S(1) & S(2), _
S(1) & S(3), _
S(2) & S(3)}

Dim Count As Integer = 0
For Each Find As String In StringsToFind
Count = 0
For Each Check As String In StringsToCheck
Select Case (Find.Count)
Case 2
If Check.Contains(Find(0)) AndAlso Check.Contains(Find(1)) Then Count += 1
Case 3
If Check.Contains(Find(0)) AndAlso Check.Contains(Find(1)) AndAlso Check.Contains(Find(2)) Then Count += 1
End Select
Next
TextBox2.AppendText("Occurances (" & S & ", " & Find & ")= " & Count.ToString & vbCrLf)
Next
Next
Loop
End Sub

Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
Dim ind As Integer = 0
For Each s As String In List_2
If Integer.TryParse(s, New Integer) Then
If s.Length = 2 Then
If Not (s(0) = s(1)) Then
TextBox3.AppendText(s & "  " & List_1(ind) & vbCrLf)
End If
End If
End If
ind += 1
Next

For I As Integer = 0 To ListCount_.Count - 1
If ListCount_(I) = ListCount_.Max Then
TextBox4.AppendText(ListCount_.Max & "    " & ListFound_(I) & vbCrLf)
End If
Next

For Each i As Integer In ListFoundOther
For j As Integer = 0 To 9
TextBox5.Text &= i.ToString & j.ToString & vbCrLf
Next
Next

End Sub

Private Sub Button6_Click(sender As System.Object, e As System.EventArgs) Handles Button6.Click

Do While sr.Peek <> -1

Dim StringToCheck As String = sr.ReadToEnd

StringToCheck = StringToCheck.Replace(vbCrLf, ",")
StringToCheck = StringToCheck.TrimEnd(CChar(","))

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

Dim Count2 As Integer = 0
For Each Find2 As String In ListDigits
Count2 = 0
For Each Check2 As String In StringsToCheck
If Check2.Contains(Find2(0)) AndAlso Check2.Contains(Find2(1)) AndAlso Check2.Contains(Find2(2)) Then
Count2 += 1
TextBox6.AppendText("Occurances ( " & Find2 & ")= " & Count2.ToString & vbCrLf)
End If
Next
Next
Loop

End Sub
End Class```

Saturday, November 4, 2017 1:43 PM

• I need TextBox6 show if count 590 = 3 not show

590 = 1

590 = 2

590 = 3

You haven't finished your previous problem:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/181429f7-92a2-4df1-b9eb-c7dc0f867707/flexible-count-2-digits?forum=vbgeneral#8a5bdebe-489b-41a5-ae05-91aae0b4a7c6

Do you mean that if the result is

590 = 1
590 = 2
590 = 3

then you want to show

590 = 3

If so, then the answer is the same as the previous time you had this problem - your textbox update should not be inside the loop, where it executes every time the loop goes around, but it should be outside the loop so it executes once only when the loop ends.

```    TextBox6.Text = ""
Dim Count2 As Integer = 0
For Each Find2 As String In ListDigits
Count2 = 0
For Each Check2 As String In StringsToCheck
If Check2.Contains(Find2(0)) AndAlso Check2.Contains(Find2(1)) AndAlso Check2.Contains(Find2(2)) Then
Count2 += 1
End If
Next
TextBox6.AppendText("Occurences ( " & Find2 & ")= " & Count2.ToString & vbCrLf)
Next```
• Marked as answer by Sunday, November 5, 2017 2:41 AM
Saturday, November 4, 2017 9:22 PM

All replies

• I need TextBox6 show if count 590 = 3 not show

590 = 1

590 = 2

590 = 3

You haven't finished your previous problem:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/181429f7-92a2-4df1-b9eb-c7dc0f867707/flexible-count-2-digits?forum=vbgeneral#8a5bdebe-489b-41a5-ae05-91aae0b4a7c6

Do you mean that if the result is

590 = 1
590 = 2
590 = 3

then you want to show

590 = 3

If so, then the answer is the same as the previous time you had this problem - your textbox update should not be inside the loop, where it executes every time the loop goes around, but it should be outside the loop so it executes once only when the loop ends.

```    TextBox6.Text = ""
Dim Count2 As Integer = 0
For Each Find2 As String In ListDigits
Count2 = 0
For Each Check2 As String In StringsToCheck
If Check2.Contains(Find2(0)) AndAlso Check2.Contains(Find2(1)) AndAlso Check2.Contains(Find2(2)) Then
Count2 += 1
End If
Next
TextBox6.AppendText("Occurences ( " & Find2 & ")= " & Count2.ToString & vbCrLf)
Next```
• Marked as answer by Sunday, November 5, 2017 2:41 AM
Saturday, November 4, 2017 9:22 PM
• Thank very much Acamar.That TextBox6 must outside If statement.

About previous problem, I try to find a RegX but I not find  that code .If you free you can show me ,How?.

Sunday, November 5, 2017 2:41 AM
• About previous problem, I try to find a RegX but I not find  that code .If you free you can show me ,How?.

If you are having difficulty with the responses in the previous thread you should post there.  But the short answer is:
- don't use a regex
- work out how you would do it with pen and paper
- use the code you have already used before when you had to do exactly the same job.

Sunday, November 5, 2017 3:23 AM