HI All
I some code that is reading the first 32 lines of a text file and paste the results into 1 text box on individual lines.
I would like each line to go into an individual text box.
I have 32 text boxes named txt_1, txt_2, txt_3
I have a variable named ThisLine holding the line of the text file.
I have a variable named textBoxName holding the name of the control.
Could anyone help me putting these together to write the line to a text box please.
Thank you.
I some code that is reading the first 32 lines of a text file and paste the results into 1 text box on individual lines.
I would like each line to go into an individual text box.
I have 32 text boxes named txt_1, txt_2, txt_3
I have a variable named ThisLine holding the line of the text file.
I have a variable named textBoxName holding the name of the control.
Could anyone help me putting these together to write the line to a text box please.
Code:
Sub ReadFile()
Me.txt_newData = ""
Me.txt_OrigData = ""
'again, we need this strange thing to exist so that ...
Dim fso As New FileSystemObject
'the file we're going to read from
Dim ts As TextStream
'... we can open a text file with reference to it
Set ts = fso.OpenTextFile(ldtFilePath, ForReading)
'keep reading in lines till Line 32
Dim ThisLine As String
Dim i As Integer
Dim txtBoxName As String
Dim txtBox As Control
i = 0
Do Until i = 32
ThisLine = ts.ReadLine
i = i + 1
'gets text box name
textBoxName = ("Me.txt_" & i)
Debug.Print textBoxName
'HERE I WOULD LIKE TO KNOW HOW TO RATHER THAN ONE TEXT BOXES PASS TO THE TEXT TO INDIVIDUAL TEXT BOX CONTROLS
Me.txt_newData = Me.txt_newData & ThisLine & vbCrLf
Me.txt_OrigData = txt_OrigData & ThisLine & vbCrLf
Loop
Me.txt_newData = Me.txt_newData & ""
ts.Close
End Sub
Thank you.