none
String In List RRS feed

  • Question

  • Hi All.

    I want try to find 3 digit number from List C_ in List DataLines by Click Button4 event.

    hope somebody to show me the correct code.My problem is;

     Find2  = {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)}

    Option Strict On
    Option Explicit On
    Option Infer Off
    
    Imports System.IO
    Imports System.Data
    Imports System.Windows.Forms
    
    Public Class Form1
        Private A_ As New List(Of String)
        Private B_ As New List(Of String)
        Private C_ As New List(Of String)
    
        Private DataLines As New List(Of String)
    
        Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            A_.Add("99")
            A_.Add("94")
            A_.Add("78")
            A_.Add("55")
            A_.Add("92")
            A_.Add("90")
            A_.Add("76")
            A_.Add("17")
            A_.Add("53")
            A_.Add("31")
    
            For i As Integer = 0 To A_.Count - 1
                TextBox1.AppendText(A_(i) & vbCrLf)
                B_.Add(A_(i))
            Next
    
        End Sub
    
    
        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            For Each i As Integer In B_
                For j As Integer = 0 To 9
                    TextBox2.Text &= i.ToString & j.ToString & vbCrLf
                    C_.Add(i.ToString & j.ToString)
                Next
            Next
        End Sub
    
        Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
    
            Dim sr As New System.IO.StreamReader("C:\Users\family\Documents\C.txt")
    
            Do While sr.Peek <> -1
                Dim StringTxt As String = sr.ReadToEnd
                TextBox3.AppendText(StringTxt & vbCrLf)
                DataLines.Add(StringTxt)
            Loop
    
        End Sub
    
        Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
    
            For Each StringToCheck As String In DataLines
                Dim StringsToCheck As String() = StringToCheck.Split(","c)
                For Each S As String In StringsToCheck
    
                    Dim Count2 As Integer = 0
    
                    For Each Find2 As String In C_
                        Find2  = {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)}
    
                        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
                        TextBox4.AppendText("Occurences ( " & Find2 & ")= " & Count2.ToString & vbCrLf)
                    Next
                Next
            Next
    
        End Sub
    
    End Class

        'TextFile=
            '8257,5321,0181,8279,8661,2120,6641,4000,0752,6975,9849,9106,7661,4522,4287,8613,3279,6296,4498,6003,8273,6642,5201
            '6235,5507,0126,9753,0354,0423,0328,6185,8449,3424,1481,1861,3234,5928,3503,1966,0513,2306,2315,3750,0190,1510,0063
            '1954,8691,7223,5869,2822,3609,3259,5081,4204,3116,5806,7052,2347,9977,5773,7416,4605,0541,0548,2138,6627,0172,0617
            '5567,5954,2521,9983,3735,7676,3644,4784,1531,1359,4466,0677,7342,5862,3487,6167,2556,3712,2165,5822,2331,8263,0190
            '6005,1426,1385,5732,2229,3699,9950,8881,6223,0893,7574,3507,7538,4630,6523,2446,2223,5198,1997,4966,3500,0590,7527
            '3754,0639,0668,9005,9257,8731,5292,6905,5002,8262,5500,5279,9306,1953,4269,3053,2751,8368,4458,1045,0421,6817,8533
            '1470,3643,6531,4029,1335,5690,6903,7829,1041,7207,2767,0617,6999,6860,4220,3164,0236,9569,2050,7224,1561,8480,0530
            '4477,9154,2541,0329,5901,1158,3605,8982,5815,0619,6410,4389,6682,6836,4296,7095,4482,5326,0477,2203,2534,3565,9312
            '7480,3341,4483,8645,2227,7407,8054,9855,0412,8538,6214,2691,1329,7259,8654,7675,3602,0815,7241,6889,0317,4419,6606
            '4428,7129,4935,9101,7429,8420,9168,3514,8014,3668,3271,0109,0844,3612,4432,9883,8109,9164,7679,8979,5889,5908,7825
            '6434,0966,4038,1775,9838,3612,3018,9552,2137,6588,8229,6916,5884,5951,1165,6312,2196,0057,3038,1454,6515,2678,8585
            '2700,5374,8402,6895,7387,1595,2202,5786,0538,3495,8433,5287,0093,1223,5416,9767,7058,6814,2242,4340,0972,6327,4255
            '9957,8230,3566,7579,9339,2197,2585,5658,1279,9387,7545,2103,9868,0046,2966,2494,8738,7994,0914,3122,2607,8977,9912
            '3212,1013,7329,4871,7478,8331,8725,2248,6774,9700,9038,1920,1025,5953,4971,4443,1583,5035,7343,9823,5595,6705,7502
            '3793,8245,8446,7865,0226,7112,1645,3462,9469,0880,2355,9163,1505,7952,6579,3114,3712,7994,8144,8904,8712,3665,1310
            '5592,7321,0432,5846,8549,1753,5901,7258,1672,9007,1767,7192,1103,9382,4812,1295,8816,2876,4554,3771,3298,5243,2648
            '5198,1505,9980,2324,3500,6259,5790,4365,0348,2855,9479,7773,5159,4595,2862,8243,2104,8432,4122,1459,1222,2096,3031



    • Edited by mipakteh Sunday, March 11, 2018 8:22 AM repair
    Sunday, March 11, 2018 7:25 AM

Answers

  • Are those examples of Find2 results actual values?  Do you know that 990 have 3 occurrences, or was 3 just an arbitrary example value?

    This is the closest I've been able to come up with based on what I can understand of your description and the code you posted.  I suspect you want to do something more like this:

    Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
        Dim sb As New System.Text.StringBuilder
        Dim counts As New Dictionary(Of String, Integer)
        For Each entry As String In C_
            counts(entry) = 0
        Next
        For Each StringToCheck As String In DataLines
            Dim StringsToCheck As String() = StringToCheck.Split(","c)
            For Each S As String In StringsToCheck
                For Each Find2 As String In C_
                    Dim searchChars As New List(Of Char)(Find2.ToCharArray)
                    For Each c As Char In S
                        If searchChars.Contains(c) Then
                            searchChars.Remove(c)
                            If searchChars.Count = 0 Then Exit For
                        End If
                    Next
                    If searchChars.Count = 0 Then counts(Find2) += 1
                Next
            Next
        Next
        For Each key As String In (From k In counts.Keys Order By k)
            sb.AppendLine("Occurences (" & key & ")= " & counts(key).ToString)
        Next
        TextBox4.Text = sb.ToString
    End Sub
    

    Here are some example results from that routine:

    Occurences (990)= 2
    Occurences (991)= 2
    Occurences (992)= 2
    Occurences (993)= 4
    Occurences (994)= 6


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"


    • Edited by Reed KimbleMVP, Moderator Tuesday, March 13, 2018 6:25 PM removed extraneous variable from code
    • Marked as answer by mipakteh Thursday, March 15, 2018 11:42 AM
    Tuesday, March 13, 2018 6:22 PM
    Moderator

All replies

  • I want try to find 3 digit number from List C_ in List DataLines by Click Button4 event.

    This code can't be right:

        Private B_ As New List(Of String)
    ...
        For Each i As Integer In B_

    Sunday, March 11, 2018 9:19 AM
  • It mean ;

     Private B_ As New List(Of Integer)
    ...
        For Each i As Integer In B_

    Sunday, March 11, 2018 2:11 PM
  • Hi All.

    I want try to find 3 digit number from List C_ in List DataLines by Click Button4 event.

    hope somebody to show me the correct code.My problem is;

     Find2  = {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)}

    Hi

    Please show an example.

    i.e. if one number is 8257 then what do you expect as a result?


    Regards Les, Livingston, Scotland

    Sunday, March 11, 2018 6:26 PM
  • It mean ;

     Private B_ As New List(Of Integer)
    ...
        For Each i As Integer In B_

    OK.  But that makes this wrong:
        Private A_ As New List(Of String)
        Private B_ As New List(Of Integer)
    ...
            B_.Add(A_(i))
    
    You should start by deciding whether you are working with strings or integers.
    Sunday, March 11, 2018 8:19 PM
  • You want assistance for a result but do not define what the result for reading all of the below should be.

    '8257,5321,0181,8279,8661,2120,6641,4000,0752,6975,9849,9106,7661,4522,4287,8613,3279,6296,4498,6003,8273,6642,5201
    '6235,5507,0126,9753,0354,0423,0328,6185,8449,3424,1481,1861,3234,5928,3503,1966,0513,2306,2315,3750,0190,1510,0063
    '1954,8691,7223,5869,2822,3609,3259,5081,4204,3116,5806,7052,2347,9977,5773,7416,4605,0541,0548,2138,6627,0172,0617
    '5567,5954,2521,9983,3735,7676,3644,4784,1531,1359,4466,0677,7342,5862,3487,6167,2556,3712,2165,5822,2331,8263,0190
    '6005,1426,1385,5732,2229,3699,9950,8881,6223,0893,7574,3507,7538,4630,6523,2446,2223,5198,1997,4966,3500,0590,7527
    '3754,0639,0668,9005,9257,8731,5292,6905,5002,8262,5500,5279,9306,1953,4269,3053,2751,8368,4458,1045,0421,6817,8533
    '1470,3643,6531,4029,1335,5690,6903,7829,1041,7207,2767,0617,6999,6860,4220,3164,0236,9569,2050,7224,1561,8480,0530
    '4477,9154,2541,0329,5901,1158,3605,8982,5815,0619,6410,4389,6682,6836,4296,7095,4482,5326,0477,2203,2534,3565,9312
    '7480,3341,4483,8645,2227,7407,8054,9855,0412,8538,6214,2691,1329,7259,8654,7675,3602,0815,7241,6889,0317,4419,6606
    '4428,7129,4935,9101,7429,8420,9168,3514,8014,3668,3271,0109,0844,3612,4432,9883,8109,9164,7679,8979,5889,5908,7825
    '6434,0966,4038,1775,9838,3612,3018,9552,2137,6588,8229,6916,5884,5951,1165,6312,2196,0057,3038,1454,6515,2678,8585
    '2700,5374,8402,6895,7387,1595,2202,5786,0538,3495,8433,5287,0093,1223,5416,9767,7058,6814,2242,4340,0972,6327,4255
    '9957,8230,3566,7579,9339,2197,2585,5658,1279,9387,7545,2103,9868,0046,2966,2494,8738,7994,0914,3122,2607,8977,9912
    '3212,1013,7329,4871,7478,8331,8725,2248,6774,9700,9038,1920,1025,5953,4971,4443,1583,5035,7343,9823,5595,6705,7502
    '3793,8245,8446,7865,0226,7112,1645,3462,9469,0880,2355,9163,1505,7952,6579,3114,3712,7994,8144,8904,8712,3665,1310
    '5592,7321,0432,5846,8549,1753,5901,7258,1672,9007,1767,7192,1103,9382,4812,1295,8816,2876,4554,3771,3298,5243,2648
    '5198,1505,9980,2324,3500,6259,5790,4365,0348,2855,9479,7773,5159,4595,2862,8243,2104,8432,4122,1459

    The below is not an explanation but merely some code and you have some expectation that deductive reasoning from viewing it will provide an explanation.

    Find2  = {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)}


    La vida loca

    Monday, March 12, 2018 2:30 AM
  • Hi Leshay,

    Number "8257,.....,......," in the List "DataLines".

    Let said we have 2 digit in List B_ "25".Then join list B_ with 0 to 9 

    Make it as "250,251,252,253,254,255,256,257,258,259".

    and put to the List C_.

    Now we want to find All digit from List C_ in List DataLines.

    250=0,251=0,252=0,.......,257=1,258=1,259=0.


    Monday, March 12, 2018 3:50 AM
  • Now we want to find All digit from List C_ in List DataLines.

    250=0,251=0,252=0,.......,257=1,258=1,259=0.

    I think that you mean "Now we want to find the number of occurrences of each item in List C_ in List DataLines.

    You should indicate which part of the code is having a problem.  Is list B_ being created correctly?  If so, is list C_ being created correctly, or is the error occurring before that?  If list C_ is being created correctly then you can use the debugger to step through the code that does the matching against DataLines and see where the problem is.

    But you need to decide whether you are working with strings or integers, because trying to match a string to an integer will be unreliable.

    Monday, March 12, 2018 3:59 AM
  • should be

       B_.Add(CInt(A_(i)))

    Monday, March 12, 2018 4:40 AM
  • Hi Leshay,

    Number "8257,.....,......," in the List "DataLines".

    Let said we have 2 digit in List B_ "25".Then join list B_ with 0 to 9 

    Make it as "250,251,252,253,254,255,256,257,258,259".

    and put to the List C_.

    Now we want to find All digit from List C_ in List DataLines.

    250=0,251=0,252=0,.......,257=1,258=1,259=0.


    Hi mipakteh,

    You got many data from C:\Users\family\Documents\C.txt in DataLines, then you use string.split to split string into stringscheck(), but I don't know what the following code means.

    For Each S As String In StringsToCheck
    
                    Dim Count2 As Integer = 0
    
                    For Each Find2 As String In C_
                        Find2 = {
                                                 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)
                        }
    
                        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
                        TextBox4.AppendText("Occurences ( " & Find2 & ")= " & Count2.ToString & vbCrLf)
                    Next
                Next

    There is error message that string() can not be converted to string. Can you describe this.

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 12, 2018 5:38 AM
    Moderator
  • I think that you mean "Now we want to find the number of occurrences of each item in List C_ in List DataLines.

    Yes,Acamar it true,I  try to find the number of occurances.By click button3. I dont know how to delcare Items of Find2 as string.In button3 I try to  use "For Each statement".

    Monday, March 12, 2018 8:01 AM
  • I dont know how to delcare Items of Find2 as string.In button3 I try to  use "For Each statement".

    Have you decided whether you are processing strings or integers?    You need to choose one or the other.
    Monday, March 12, 2018 8:26 AM
  • Let said working with all string.

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

     For Each i As String In B_
                For j As Integer = 0 To 9
                    TextBox2.Text &= i.ToString & j.ToString & vbCrLf
                    C_.Add(i.ToString & j.ToString)
                Next
            Next

    Now, How to declare all Items in C_ List.

    
                    For Each Find2 As String In C_
                        Find2 = {
                                                 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 Each Find2 As String In C_
                        Find2 = {
                                                 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)
                        }
    • Edited by mipakteh Monday, March 12, 2018 9:12 AM
    Monday, March 12, 2018 8:53 AM
  • Let said working with all string.

    If i is a string, then do not use i.ToString.

      C_.Add(i & j.ToString)

    Is the B_ List correct? (You should not just ignore questions - they are asked for a reason).

    Monday, March 12, 2018 9:13 AM
  •  Private A_ As New List(Of String)
        Private B_ As New List(Of String)
        Private C_ As New List(Of String)

        Private DataLines As New List(Of String)

        Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            A_.Add("99")
            A_.Add("94")
            A_.Add("78")
            A_.Add("55")
            A_.Add("92")
            A_.Add("90")
            A_.Add("76")
            A_.Add("17")
            A_.Add("53")
            A_.Add("31")

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


        End Sub

        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            For Each i As String In B_
                For j As Integer = 0 To 9
                    TextBox2.Text &= i & j.ToString & vbCrLf
                    C_.Add(i & j.ToString)
                Next
            Next
        End Sub
    • Edited by mipakteh Monday, March 12, 2018 1:33 PM add
    Monday, March 12, 2018 1:29 PM
  • Hi

    WHAT RESULTS DO YOU SEE and WHAT RESULTS DO YOU WANT TO SEE?

    As I asked before, show examples!


    Regards Les, Livingston, Scotland

    Monday, March 12, 2018 2:11 PM
  • Please answer the question asked above:  Is list B_ being created correctly?  If so, is list C_ being created correctly, or is the error occurring before that? 

    List B_ seems to be identical to list A_, so it is difficult to see what you are trying to do.  But if you can confirm that list C_ is correct, then you can step through the following code with the debugger to see what's happening.

    Monday, March 12, 2018 9:16 PM
  • Hi Leshay,

    Number "8257,.....,......," in the List "DataLines".

    Let said we have 2 digit in List B_ "25".Then join list B_ with 0 to 9 

    Make it as "250,251,252,253,254,255,256,257,258,259".

    and put to the List C_.

    Now we want to find All digit from List C_ in List DataLines.

    WHAT RESULTS DO YOU WANT TO SEE?

    250=0,251=0,252=0,.......,257=1,258=1,259=0.

    Tuesday, March 13, 2018 5:54 AM
  • Hi Kunmo bu.

    There is error message that string() can not be converted to string. Can you describe this.

    I don't know how to write Items of string in Find2.

     For Each Find2 As String In C_
                        Find2 =???????? what code can be here.

    Tuesday, March 13, 2018 5:59 AM
  • I think List B_ and C_ are correctly created.It become error when at code Find2 string.

    Click button3.

     For Each Find2 As String In C_
                        Find2  =?
    

    Tuesday, March 13, 2018 6:08 AM
  • There is error message that string() can not be converted to string. Can you describe this.

    I don't know how to write Items of string in Find2.

    What is the line of code that has the error? 
    What is the exact error message (not a summary)?
    Does the error message show a suggested fix?

    Show an example for C_. 
    Select some items from the example C_ and show what the result for Find2 should be for each example.

    Tuesday, March 13, 2018 6:37 AM
  • 1.What is the line of code that has the error?  

    find2 = {S(0), S(1), S(2) _
                                & S(0), S(2), S(1) _
                                & S(1), S(0), S(2) _
                                & S(1), S(2), S(0) _
                                & S(2), S(0), S(1) _
                                & S(2), S(1), S(0)}

    2.What is the exact error message (not a summary)?

    Error 1 Value of type '1-dimensional array of String' cannot be converted to 'String'. C:\Users\family\documents\visual studio 2010\Projects\count threeDigit\count threeDigit\Form1.vb 68 29 count threeDigit
    3.Does the error message show a suggested fix?

    before Debug

    Show an example for C_. 

    990
    991
    992
    993
    994
    995
    996
    997
    998
    999
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319


    Base on Text file;

    8257,5321,0199,8279,8661,2120,6299,4000,0752,6975,9809,9406,7661,4522,4287,8613,3279,6296,4498,6003,8273,6642,5201
    6235,5507,0126,9753,0354,0493,0328,6185,8449,3424,1481,1861,3234,5928,3503,1966,0513,2306,2315,3750,0490,1510,9913
    1954,9691,7223,0899,1992,3609,3259,5081,4204,3116,5806,7052,2347,9917,5773,7416,4605,0541,0548,2134,6627,0172,0617

    show what the result for Find2 should be for each example



    990 find2 is 3
    991 find2 is 4
    992 find2 is 2
    .......
    .......

    Tuesday, March 13, 2018 1:26 PM
  • Are those examples of Find2 results actual values?  Do you know that 990 have 3 occurrences, or was 3 just an arbitrary example value?

    This is the closest I've been able to come up with based on what I can understand of your description and the code you posted.  I suspect you want to do something more like this:

    Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
        Dim sb As New System.Text.StringBuilder
        Dim counts As New Dictionary(Of String, Integer)
        For Each entry As String In C_
            counts(entry) = 0
        Next
        For Each StringToCheck As String In DataLines
            Dim StringsToCheck As String() = StringToCheck.Split(","c)
            For Each S As String In StringsToCheck
                For Each Find2 As String In C_
                    Dim searchChars As New List(Of Char)(Find2.ToCharArray)
                    For Each c As Char In S
                        If searchChars.Contains(c) Then
                            searchChars.Remove(c)
                            If searchChars.Count = 0 Then Exit For
                        End If
                    Next
                    If searchChars.Count = 0 Then counts(Find2) += 1
                Next
            Next
        Next
        For Each key As String In (From k In counts.Keys Order By k)
            sb.AppendLine("Occurences (" & key & ")= " & counts(key).ToString)
        Next
        TextBox4.Text = sb.ToString
    End Sub
    

    Here are some example results from that routine:

    Occurences (990)= 2
    Occurences (991)= 2
    Occurences (992)= 2
    Occurences (993)= 4
    Occurences (994)= 6


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"


    • Edited by Reed KimbleMVP, Moderator Tuesday, March 13, 2018 6:25 PM removed extraneous variable from code
    • Marked as answer by mipakteh Thursday, March 15, 2018 11:42 AM
    Tuesday, March 13, 2018 6:22 PM
    Moderator
  • Error 1 Value of type '1-dimensional array of String' cannot be converted to 'String'. C:\Users\family\documents\visual studio 2010\Projects\count threeDigit\count threeDigit\Form1.vb 68 29 count threeDigit

    Find2 is declared as a string.
                    For Each Find2 As String In C_
    You are trying to initialize Find2 with an array initializer:
                        Find2  = {S(0) & S(1) & S(2), _  ...
    The compiler is therefore confused about whether you want Find2 to be a string or an array of string.  I suspect that the problem is that the first line should be
                    For Each S As String In C_

    Is that example list for C_ correct?

    You were asked to check the value of Find2.  Instead you have provided results which appear to be for the whole program (Count2).    You can't debug your program using the final result - you have to do it one step at a time.   Insert a breakpoint at the start of the loop and make sure Find2 is now being created with the correct values for the first item from C_.    Then insert a breakpoint at the end of the loop and check that the count is correct for the first item in Find2.  And so on.   There is no shortcut - you need to confirm each part of the code.


    • Edited by Acamar Tuesday, March 13, 2018 9:59 PM fmt
    Tuesday, March 13, 2018 9:05 PM
  • yes, List C_ are correctly.I think S is not in List C_, S in StringsToCheck

    and Find2 as string to find .

    Reed Kimble code nearest way what i try to do but problem like a previous version.

    Digit 940 count 3, It should be count 4 because of digit 0940

    Wednesday, March 14, 2018 12:54 PM
  • yes, List C_ are correctly.I think S is not in List C_, S in StringsToCheck

    and Find2 as string to find .

    Reed Kimble code nearest way what i try to do but problem like a previous version.

    Digit 940 count 3, It should be count 4 because of digit 0940

    Given the sample data you provided, the code I wrote returns a count of 5 for 940:

    Occurences (940)= 5
    Occurences (941)= 9
    Occurences (942)= 8
    Occurences (943)= 5
    Occurences (944)= 4

    Where did you come up with the numbers 3 and 4?

    How about reducing the sample size to just a few values?  Pick just one or two source number (eg 940, 941) then create some sample data with just five or six values and show us what the expected count results would be for those two source numbers against the five or six data values.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"


    Wednesday, March 14, 2018 4:09 PM
    Moderator
  • sorry Reed Kimble Using the newest text file

    8257,5321,0199,8279,8661,2120,6299,4000,0752,6975,9809,9406,7661,4522,4287,8613,3279,6296,4498,6003,8273,6642,5201
    6235,5507,0126,9753,0354,0493,0328,6185,8449,3424,1481,1861,3234,5928,3503,1966,0513,2306,2315,3750,0490,1510,9913
    1954,9691,7223,0899,1992,3609,3259,5081,4204,3116,5806,7052,2347,9917,5773,7416,4605,0541,0548,2134,6627,0172,0617

    Thursday, March 15, 2018 5:50 AM
  • sorry Reed Kimble Using the newest text file

    You should start over: there ae too many different test files and too many different results.

    Post the test data file you are actually using and some sample results from that test file, in one post. Then don't change it.


    • Edited by Acamar Thursday, March 15, 2018 7:16 AM sp
    Thursday, March 15, 2018 7:16 AM
  • ok

    Thursday, March 15, 2018 8:23 AM