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
Joel Coehoorn
419k114 gold badges582 silver badges820 bronze badges
asked Jun 12, 2011 at 22:58
Kuzon
8225 gold badges21 silver badges50 bronze badges
2 Answers 2
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
answered Jun 12, 2011 at 23:08
Tim Schmelter
462k79 gold badges721 silver badges981 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Try setting that last line to Loop Until ioLine is nothing
answered Jun 12, 2011 at 23:05
Prescott
7,4225 gold badges53 silver badges70 bronze badges
1 Comment
Kuzon
Thanks for the reply, but it still doesn't work... Any other ideas? It just stops on that code. Would there be a way I can restart the code?
lang-vb