Okay, Jim. One last try here before I head out for the weekend.
I ran the code. It creates the output file, but nothing is in it. I've pasted the code one more time here.
By the way, I really appreciate your help with this. I'm slowly learning how to use VB. Thanks a lot!Code:Private Sub Command1_Click() Dim TextLine$, Filename$ Dim FileHandle As Integer Dim aArrays() As tElements, aDataIn() As String, i As Long Dim j As Long, sOut As String Filename$ = "C:\data.txt" Open "C:\output.txt" For Output As #2 If Dir(Filename$) = "" Then Exit Sub FileHandle = FreeFile Open Filename$ For Input As #FileHandle ReDim aArrays(0) ReDim aArrays(0).Elements(0) Do While Not EOF(FileHandle) Line Input #FileHandle, TextLine$ Do While InStr(TextLine$, " ") > 0 'remove the double spaces, make them equally one space per element TextLine$ = Replace$(TextLine$, " ", " ") Loop aDataIn = Split(TextLine$, " ") If UBound(aArrays) < UBound(aDataIn) Then For i = UBound(aArrays) To UBound(aDataIn) ReDim Preserve aArrays(i) ReDim Preserve aArrays(i).Elements(0) Next i End If For i = 0 To UBound(aDataIn) ReDim Preserve aArrays(i).Elements(UBound(aArrays(i).Elements) + 1) aArrays(i).Elements(UBound(aArrays(i).Elements)) = aDataIn(i) Next i For i = LBound(aArrays(0).Elements) To UBound(aArrays(0).Elements) For j = LBound(aArrays) To UBound(aArrays) - 1 Print #2, aArrays(j).Elements(i), 'store the values as aligned text. Next j Next i Loop Close #FileHandle End Sub![]()




Reply With Quote