Visual Basic ReadAllText

Associate
Joined
14 Nov 2005
Posts
1,396
Location
Belfast
Okay so I am trying to read data from a .csv file and import each line to be an option in a combo box in visual basic but instead of reading each word it makes every letter an option instead. Is there a way to make it so it takes it after a new line instead of every letter?

Code:
For Each EngModule As String In My.Computer.FileSystem.ReadAllText(WriteLocation)
                cmbModule.Items.Add(EngModule)
Next

EDIT: Never mind turns out there's a ReadAllLines I somehow managed to miss while finding readalltext on msdn!
 
Last edited:
ReadAllText returns a string. If you enumerate a string it returns an array of char, so that's why it's iterating over each letter.

Instead, you need to split the ReadAllText result by line endings and then loop over that.

Or use ReadAllLines. That's good too :)
 
Last edited:
Back
Top Bottom