Q:

VB.NET Text File Parse Many Entries One Line Separated by a Space

and thank you for any guidance you can give.
I want to read a text file and capture all values with a space as the separater, and input each entry into a field on my SQL Server table.  Sometimes the entries are three characters, sometimes the entries are four characters.
Example of text file entry:
  YYYY: AAA BBBB CCCC DDDD EEEE
        FFF GGG HHH III JJJ LLL

  ZZZZ: 111 2222 3333 4444 5555
        777 888 999 000 123 456

I'm using a StreamReader.  I'm just a bit new to all this.  I really appreciate your patience with me.
Here is the latest attempt.  It was at this point that I realized I didn't know how to go through the entire line without knowing how to parse by using the space as the indicator to pull the next "thing."  I have been searching for a while.  I just don't seem to be searching for the right topics\commands.
Do
    Dim line As String = Streamy.ReadLine
    Dim Model As String = ""

    If line.Contains("MODEL") Then
        Dim newModelData As New ModelData
        Model = line.Substring(6, 3)
        newModelData.Model = line.Substring(6, 3)

        If newModelData.Model = "   " Then
            line.Skip(1)
        Else
            ModelDataList.Add(newModelData)
        End If
    End If

    If line.Contains("YYYY") Then
        Dim newModelData As New ModelData
        newModelData.Model = Model
        'This part below is where I realized I don't understand 
        'how to parse the line.  I've searched online, but 
        'apparently I just don't know the right topic to search for.

        newModelData.SomeModelInfo = line.Substring(23, 3)

        ModelDataList.Add(newModelData)
    End If

    Loop Until Streamy.EndOfStream
    db.BulkInsertAll(ModelDataList)
    Streamy.Close()
 End Using

End Using
    End Sub

A:

You can separate a string separated by spaces by using the .Split method - Like this:
Dim line As String = Streamy.ReadLine
Dim lineParts() As String() = line.Split(" "c)

What happens here is that lineParts  is declared as a string array and the bit of code after the = sign splits the string at every point a space occurs.
The odd bit of code her - " "c is to make sure that " " is treated as a char type rather than a string type.
What you end up with is an array that contains only your text.
If you have spaces at the beginning or end of your line, you will have empty elements in your array with nothing in them. So I would suggest that you also use the .Trim method. So your code looks like this now:
Dim line As String = Streamy.ReadLine
line = line.Trim(" "c)
Dim lineParts() As String() = line.Split(" "c)

now you can just work your way through the array of lineParts

