VBA‎ > ‎

File Text


Materi ALG1 tadi adalah File Teks 

Private Sub bacaFile()

    Dim InputData
    Open "D:\test.txt" For Input As #1    ' Open file for input.
    Do While Not EOF(1)    ' Check for end of file.
        Line Input #1, InputData    ' Read line of data.
        'Debug.Print InputData    ' Print to the Immediate window.
        Selection.TypeText InputData & vbCrLf
    Loop
    Close #1    ' Close file.


End Sub


Private Sub tulisFile()

    Open "D:\test.txt" For Output As #1
    For i = 1 To 100
        Write #1, Int(Rnd() * 1000)
    Next i
    Close #1
    
End Sub



Comments