Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27349

VS 2010 Unable to convert a For-Next loop into Do-Loop.

$
0
0
Hello
I am trying to convert a for next loop into a do loop because I want to add a condition.
This code works perfectly:
Code:

        Dim LastNonEmpty As Integer = -1
        For i As Integer = 0 To mnar.Length - 1
            If mnar(i) <> "" Then
                LastNonEmpty += 1
                mnar(LastNonEmpty) = mnar(i)
            End If
        Next

But when I converted it:
Code:

i = 0
Do while i = wnar.Length - 1
  If wnar(i) <> "" Then
      LastNonEmpty2 += 1
      wnar(LastNonEmpty2) = wnar(i)
  End If
Loop

This doesn't work at all.
Please suggest me the correct code.
Or tell me how to add condition in a for next loop.

Viewing all articles
Browse latest Browse all 27349

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>