FileSystemObject
읽기
1 2 3 4 5 6 7 8 9 10 |
Function Dir_OpenFile(ByVal File As String) as string Dim fso, FileWriter As Object Set fso = CreateObject("scripting.FileSystemObject") Set FileWriter = fso.OpenTextFile(File) Dir_OpenFile = FileWriter.ReadAll FileWriter.Close End Function |
쓰기
1 2 3 4 5 6 7 8 9 10 11 |
Public Sub Dir_WriteFile(ByVal File As String, ByVal Text As String) Dim fso, FileWriter As Object Set fso = CreateObject("scripting.FileSystemObject") Set FileWriter = fso.CreateTextFile(File, True) FileWriter.Write Text FileWriter.Close End Sub |
참조 : https://starplaying.tistory.com/316
#fileNumber
읽기
1 2 3 4 5 6 7 |
Open "fileName" For Input As #fileNumber VB Statements Input #fileNumber, variable VB Statements Close #fileNumber |
쓰기
1 2 3 4 5 6 7 |
Open "fileName" For Output As #fileNumber VB Statements Print #fileNumber, Contents VB Statements Close #fileNumber |
참조 : https://aroundck.tistory.com/1917
활용
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Private Sub Form_Load() Dim sXML As String sXML = modFunction.Dir_OpenFile("D:\samples\Test.xml") 'Debug.Print sXML '//xml.ParseXML (sXML) 'Call SetCardData '컬렉션에 저장 End Sub |
*모듈 : modFunction
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
'일기 Function Dir_OpenFile(ByVal File As String) As String Dim fso, FileWriter As Object Set fso = CreateObject("scripting.FileSystemObject") Set FileWriter = fso.OpenTextFile(File) Dir_OpenFile = FileWriter.ReadAll FileWriter.Close End Function '쓰기 Public Sub Dir_WriteFile(ByVal File As String, ByVal Text As String) Dim fso, FileWriter As Object Set fso = CreateObject("scripting.FileSystemObject") Set FileWriter = fso.CreateTextFile(File, True) FileWriter.Write Text FileWriter.Close End Sub |