0% found this document useful (0 votes)
29 views20 pages

Bekerja Dengan File: Click To Edit Master Subtitle Style

The document discusses different types of files (sequential, random, binary) and how to open, read from, and write to files in different modes (input, output, random, append, binary) using Visual Basic. It provides code examples for sequentially reading from and writing to files, as well as randomly accessing records in a file to read and write data. The examples show opening a file, reading/writing field data to text boxes, and closing the file.

Uploaded by

edsykemp
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views20 pages

Bekerja Dengan File: Click To Edit Master Subtitle Style

The document discusses different types of files (sequential, random, binary) and how to open, read from, and write to files in different modes (input, output, random, append, binary) using Visual Basic. It provides code examples for sequentially reading from and writing to files, as well as randomly accessing records in a file to read and write data. The examples show opening a file, reading/writing field data to text boxes, and closing the file.

Uploaded by

edsykemp
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Bekerja dengan File

Click to edit Master subtitle style


5/21/12

5/21/12

Jenis File

Sequential

Data tertulis berurutan Data tertulis acak Data tertulis pada level byte

Random

Binary

5/21/12

Membuka File

Open namafile [For Mode] [AccessRestriction] [LockType] As #noFile Len=Len(record)

Open MyFile.Txt For Random Read Lock Read As #1

5/21/12

Mode Akses

1. Input 2. Output 3. Random 4. Append 5. Binary

5/21/12

SeqOut

5/21/12

Private Sub Form_Load() 'Pastikan semua textbox dalam keadaan kosong Dim Hit As Integer For Hit = 0 To 6 TxtField(Hit).Text = "" Next Hit 'Gunakan perintah berikut untuk membuka dan menambahkan data

5/21/12

Private Sub CmdWrite_Click() Dim Hit As Integer Dim Hit2 As Integer For Hit = 0 To 6 Write #1, TxtField(Hit).Text Next Hit For Hit2 = 0 To 6

5/21/12

Private Sub CmdCancel_Click() Dim Hit As Integer For Hit = 0 To 6 TxtField(Hit).Text = "" Next Hit TxtField(0).SetFocus End Sub Private Sub CmdExit_Click()

5/21/12

SeqIn

5/21/12

Private Sub Form_Load() Dim Hit As Integer For Hit = 0 To 6 TxtField(Hit).Text = "" Next Hit Open "D:\NamaMahasiswa\BukuAlamat.txt" For Input As #1 End Sub

Private Sub CmdBaca_Click() On Error GoTo Errlanjut Dim Hit As Integer Dim Hit2 As Integer Dim IsiField For Hit2 = 0 To 6 TxtField(Hit2).Text = "" Next Hit2
5/21/12

5/21/12

RandomOut

5/21/12

RandomIn

5/21/12

MODUL

RandomOut
Option Explicit Dim OutRec As DafTel Dim Posisi As Integer Dim lastRecord As Integer

5/21/12

Private Sub CmdExit_Click() Close

5/21/12

RandomOut
Private Sub Form_Load() Dim Hit As Integer For Hit = 0 To 7 TxtField(Hit).Text = "" Next Hit 'Gunakan perintah berikut untuk membuka dan menambahkan data 'ke dalam file yang dituju

Private Sub CmdWrite_Click() Dim Hit As Integer On Error GoTo Lanjut Posisi = Posisi + 1 ' tambah satu ke no record TxtField(0).Text = Posisi OutRec.NoID = Posisi OutRec.NamaAwal = TxtField(1).Text OutRec.NamaAkhir = TxtField(2).Text OutRec.Alamat = TxtField(3).Text OutRec.Kota = TxtField(4).Text OutRec.Propinsi = TxtField(5).Text
5/21/12

5/21/12

Private Sub CmdCancel_Click() Dim Hit As Integer For Hit = 0 To 6 TxtField(Hit).Text = "" Next Hit TxtField(0).SetFocus End Sub Private Sub CmdExit_Click()

5/21/12

RandomIn
Private Sub Form_Load() ' Pastikan semua textBox kosong Dim Hit As Integer For Hit = 0 To 7 TxtField(Hit).Text = "" Next Hit ' untuk menjaga file ini terpisah dari file sequential ' buka file baru

Private Sub CmdBaca_Click() On Error GoTo Errlanjut Dim Hit As Integer Dim Hit2 As Integer Dim Posisi Posisi = TxtField(0).Text Get #1, , InRec TxtField(1).Text = InRec.NamaAwal TxtField(2).Text = InRec.NamaAkhir TxtField(3).Text = InRec.Alamat
5/21/12

You might also like