Skip to main content

Read or Write a Text File

Article # 304830 - Page views: 385


 QAID # 17783 Published

Question / Problem:

Read or Write a Text File

Answer / Solution:

Use the scripts below to read from and write to a text file. Reading text:

Private Function ReadLineFromFile(Filename As String) As String
   Dim TextLine As String
   ' check if file exists
   If Len(Dir(Filename)) = 0 Then
      ReadLineFromFile = ""
      Exit Function
   End If
   Open Filename For Input As #1
   Line Input #1, TextLine
   Close #1
   ReadLineFromFile = TextLine
End Function

Writing text:

Private Sub WriteLineToFile(Filename As String, Line As String)
   Open Filename For Output As #1
   Print #1, Line
   Close #1
End Sub 

Applies to: 

Product Version Category
AXPRO 5.5 Project Builder
  • Was this article helpful?