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. 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 jinglehimerschmidt1234
123456 7890 John Doe1234
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))
Do Until (fIn.EndOfStream)
sArry = Split(fIn.ReadLine, ",")
If UBound(sArry) = 8 Then _
fOut.WriteLine(sArry(4) & " " & sArry(2) & " " & sArry(1) & " " & sArry(0) & "TEXT")