For Each Vs For i=0 to RRS feed

  • Question

  • User1435413075 posted


    I have a multiline Texbox with a list of serial numbers (text)

    I Split it

    SNlist = PSnTx.Text.Split(vbCrLf)

    Problem 1 : there is an ASCII 10 char left in there so it has to be removed.

    there is 2 ways to do it?

    For i As Integer = 0 To SNlist.Length - 1
        Dim K As Integer = Asc(SNlist(i).Substring(0, 1))
        If K = 10 Then SNlist(i) = SNlist(i).Substring(1)


     For Each SN As String In SNlist
             Dim K As Integer = Asc(SN.Substring(0, 1))
            If K = 10 Then SN = SN.Substring(1)

    the For each DOES NOT Work

    the For i=0 to Does

    Can any body explain me why?

    Many thanks

    Monday, November 28, 2011 5:51 AM