Read / Write - Open / Close text files. This code is short, quick, and concise. If you have any pro
Read / Write - Open / Close text files. This code is short, quick, and concise. If you have any problems with it, let me know... or fix it,
Rate Read / Write - Open / Close text files. This code is short, quick, and concise. If you have any pro
(1(1 Vote))
'-- Contact me at: [email protected]
Public Function ReadFile(strPath As String) As String
On Error GoTo eHandler
Dim iFileNumber As Integer
Dim blnOpen As Boolean
iFileNumber = FreeFile
Open strPath For Input As #iFileNumber
blnOpen = True
ReadFile = Input(LOF(iFileNumber), iFileNumber)
eHandler:
If blnOpen Then Close #iFileNumber
If Err Then MsgBox Err.Description, vbOKOnly + vbExclamation, Err.Number & " - " & Err.Source
End Function
Public Function WriteFile(strPath As String, strValue As String) As Boolean
On Error GoTo eHandler
Dim iFileNumber As Integer
Dim blnOpen As Boolean
iFileNumber = FreeFile
Open strPath For Output As #iFileNumber
blnOpen = True
Print #iFileNumber, strValue
eHandler:
If blnOpen Then Close #iFileNumber
If Err Then
MsgBox Err.Description, vbOKOnly + vbExclamation, Err.Number & " - " & Err.Source
Else
WriteFile = True
End If
End Function
Read / Write - Open / Close text files. This code is short, quick, and concise. If you have any pro Comments
No comments yet — be the first to post one!
Post a Comment