开发者

VB program stops after loop

I am using VB 2101 express, I am try to right this program but it will not go past the end of my loop, does anyone know why?

If (Not System.IO.Directory.Exists(root + "\setting")) Then
    System.IO.Directory.CreateDirectory(root + "\setting")
End If

'loads world settings
If File.Exists(root + "\setting\world.txt") Then
    Dim ioFile As New StreamReader(root + "\setting\world.txt")
    Dim ioLine As String ' Going to hold one line at a time
    Dim ioLines As String ' Going to hold whole file

    ioLine = ioFile.ReadLine
    ioLines = ioLine

    Do
         ioLine = ioFile.ReadLine
         ioLines = ioLines & vbCrLf & ioLine
         cmbworld.Items.Add开发者_如何转开发(ioLine)
    Loop Until ioLine = "" '***<--- IT STOPS HERE!***

Else
    System.IO.File.Create(root + "\setting\world.txt")
End If


Wouldn't this be simplier?

For Each line As String In File.ReadLines("root + "\setting\world.txt"")
    If line.Length <> 0 Then
        cmbworld.Items.Add(line)
    End If
Next line

MSDN: File.ReadLines Method (String)


Try setting that last line to Loop Until ioLine is nothing

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜