Spidermans_DarkSide
Hi,
( Please MARK AS ANSWER if the below program is of any use to you. )
I've sussed it so far as Excel is concerned.
My program produces a CSV (comma separated value ) text file and for your example it produces>>
041,F/M #59 K155,786201 PP0.5ml 0003-2,0003-2,68.00,2/22/2007 11:08:52 AM,2/27/2007 11:00:00 PM,2/28/2007 1:01:52 AM,108,7312,0,216,
001,Engel #1 150T,L723 16x100mm Non-ridged Tube,920206,7.80,2/19/2007 11:24:10 AM,2/27/2007 11:00:00 PM,2/28/2007 7:00:00 AM,0,28800,28800,0,
Save the above text as outputFile.csv from NotePad and load it into Excel to see what i mean.
It produces 1 blank row + 2 rows of data as you would expect in an Excel Form.
However loading it into MicroSoft Office 2007-Access field 4 and a few others are confused by the dataType for some reason.
Put the line>>
Imports System.IO 'at the top of your code window.>>
Rename your input file to inputFile.txt and put it into C:\ drive then run this>>
The outputFile.csv will appear as an Excel file.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sr As New StreamReader("C:\inputFile.txt")
Dim sw As New StreamWriter("C:\outputFile.csv")
Dim myLine As String
Do While sr.Peek >= 0
myLine = sr.ReadLine
If myLine.Length >= 4 Then
If Mid(myLine, 1, 5) = "[Job]" Then
sw.WriteLine()
End If
If Mid(myLine, 1, 4) = "Line" Then
sw.Write(myLine.Substring("Line".Length + 1) & ",")
End If
If Mid(myLine, 1, 7) = "Machine" Then
sw.Write(myLine.Substring("Machine".Length + 1) & ",")
End If
If Mid(myLine, 1, 11) = "Description" Then
sw.Write(myLine.Substring("Description".Length + 1) & ",")
End If
If Mid(myLine, 1, 10) = "PartNumber" Then
sw.Write(myLine.Substring("PartNumber".Length + 1) & ",")
End If
If Mid(myLine, 1, 12) = "NominalCycle" Then
sw.Write(myLine.Substring("NominalCycle".Length + 1) & ",")
End If
If Mid(myLine, 1, 12) = "JobStartDate" Then
sw.Write(myLine.Substring("JobStartDate".Length + 1) & ",")
End If
If Mid(myLine, 1, 9) = "StartDate" Then
sw.Write(myLine.Substring("StartDate".Length + 1) & ",")
End If
If Mid(myLine, 1, 8) = "StopDate" Then
sw.Write(myLine.Substring("StopDate".Length + 1) & ",")
End If
If Mid(myLine, 1, 6) = "Cycles" Then
sw.Write(myLine.Substring("Cycles".Length + 1) & ",")
End If
If Mid(myLine, 1, 16) = "RuntimeInSeconds" Then
sw.Write(myLine.Substring("RuntimeInSeconds".Length + 1) & ",")
End If
If Mid(myLine, 1, 17) = "DowntimeInSeconds" Then
sw.Write(myLine.Substring("DowntimeInSeconds".Length + 1) & ",")
End If
If Mid(myLine, 1, 9) = "PartsMade" Then
sw.Write(myLine.Substring("PartsMade".Length + 1) & ",")
End If
End If
Loop
sw.Close()
sr.Close()
' I was hoping to open ACCESS as a PROCESS here
' with the csv file created above. Anyone want to help further
End Sub
Regards,
S_DS