Originally Posted by
av8tordude
GTO, you are right. I discovered that when writing the info to the text file, the code creates a enter input in the text file (The cursor was not at the end of the line of text; like hitting the enter button to move to the next line). So my question now, when writing the info to the textfile, how do I prevent the code from creating an Enter input?
I think you would need to show an example file so that we could see how it is actually constructing/readin the textfile. .xls Format if possible, as I do not have access to .xlsm until Monday.
Here was my admittedly (and early-bound) simplistic testing:
Userform1:
Option Explicit
Private Sub CommandButton1_Click()
Dim sData1 As Variant, sData2 As Variant, sData3 As Variant, sFName As String
Dim FSO As FileSystemObject
Dim fsoTStream As TextStream
Dim strLine As String
sData1 = txtData_1.Value
sData2 = txtData_2.Value
sData3 = txtData_3.Value
sFName = txtFName.Value
Set FSO = New FileSystemObject
Set fsoTStream = FSO.CreateTextFile(ThisWorkbook.Path & "\Test.txt", True)
fsoTStream.WriteLine sData1 & vbTab & sData2 & vbTab & sData3 & vbTab & sFName
fsoTStream.Close
Unload Me
UserForm2.Show
End Sub
UserForm2:
Private Sub UserForm_Initialize()
Dim FSO As FileSystemObject
Dim fsoTStream As TextStream
Set FSO = New FileSystemObject
Set fsoTStream = FSO.OpenTextFile(ThisWorkbook.Path & "\Test.txt", ForReading, False, TristateUseDefault)
TextBox1.Value = Split(fsoTStream.ReadLine, vbTab)(3)
End Sub