Okay I solved the first part to my problem and now I have run into another situation. I have been trying to resolve this for almost a week and cannot come up with or find anything that works. I am using VB 2005 Express. I have extracted data from one file and put it into another file. (.dat) My problem is the program that is reading the file needs it to be formatted in a specific way to be able to read it.
the first array is 13 spaces total, the second array is 8 spaces total, the third array is 20 spaces total and the last is 4 spaces total. Meaning with data that array needs to be that amount of spaces.
My problem is the third array, this is where names are inputted and they can vary in length but the space can only accommodate 20 characters&spaces (total). All of the other inputs are pretty much constant.
Here is and example of what the output should look like:
123456 7890 johnjacob jinglehime1234
123456 7890 John Doe 1234
Hopefully that gives you an idea of what I am dealing with. Notice that in the first row the name was cut off...that's okay. In my current code the output looks like this and my program won't read it:
123456 7890 johnjacob jinglehimersmith1234
123456 7890 John Doe1234
Please help...here is what I have so far...some of you may recognize it as you have helped me with it before:
Imports System.IO
Module Mod1
Sub Main()
Dim fIn As StreamReader
Dim fOut As StreamWriter
Dim sArry() As String
'This reads file and creates/overwrites new .dat
fIn = New StreamReader(New FileStream("c:\testfile1.dat", FileMode.Open))
fOut = New StreamWriter(New FileStream("c:\testfile2.dat", FileMode.Create))
'Parse arrays
Do Until (fIn.EndOfStream)
sArry = Split(fIn.ReadLine, ",")
If UBound(sArry) = 8 Then _
fOut.WriteLine(sArry(4) & " " & sArry(2) & " " & sArry(1) & " " & sArry(0) & "TEXT")
Loop
fIn.Close()
fOut.Close()
End Sub
End Module