1

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

2 Answers 2

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

MSDN: File.ReadLines Method (String)

answered Jun 12, 2011 at 23:08
Sign up to request clarification or add additional context in comments.

Comments

0

Try setting that last line to Loop Until ioLine is nothing

answered Jun 12, 2011 at 23:05

1 Comment

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?

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.