Hi guys, I have written a simple script to get a bunch of lines from a text file (they will be filenames eventually) which are split by new lines and puts each one into an array..

Dim ary() As String

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If My.Computer.FileSystem.FileExists("C:\MenuFiles.txt") Then
            Dim str As String = My.Computer.FileSystem.ReadAllText("C:\MenuFiles.txt")
            ary = str.Split(vbNewLine)

            Me.TextBox1.Text = ary(1)

.............now with ary(0) it is fine and desplayed properly but with the latter elements of the array I get a "square" (which is the 'icon' for a new line is it not?) before each name.

see this screenshot...


The only thing I can do for now is either use the substring function to remove the first character from all array values after 0 but I don't like that because it's messy and what if the split "works" as I want it to one one of the lines and knocks of the first character when I don't want it to.

I have found lots on the web about splitting by new line but none seem to cover this issue.

Edited by vbnoob: n/a

7 Years
Discussion Span
Last Post by apegram
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.