Populate Textbox from Txt File

Alan McGowan

Senior Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
I am trying to populate multiple textboxes based on the value on each line in a txt file.

Code:
Dim fn As String, ff As Integer, txt As String
fn = "D:\filemail\settings.txt"               '< --- .txt file path
txt = Space(FileLen(fn))
ff = FreeFile
Open fn For Binary As #ff
Get #ff, , txt
Close #ff
TextBox1.Value = txt
Using the above code I can populate textbox1 with the value in the first line of the text file (settings.txt), but how would I populate textbox2 with the value in the second line in the text file and so on. Each line is either YES or NO in the text file
 

Alan McGowan

Senior Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
Sorted by adding the following code

Code:
 Dim myArray() As String
  'Use Split function to return a zero based one dimensional array.
  myArray = Split(txt, vbCrLf)

    TextBox2.Value = myArray(0)
    TextBox3.Value = myArray(1)
    TextBox5.Value = myArray(2)
    TextBox6.Value = myArray(3)
    TextBox7.Value = myArray(4)
 

Similar threads

Top