Would you like to react to this message? Create an account in a few clicks or log in to continue.


 
IndeksBSI-PCLatest imagesPencarianPendaftaranLogin

 

 Perintah VB Akses File

Go down 
3 posters
PengirimMessage
agoenxz21
Moderator
Moderator
agoenxz21


Male
Jumlah posting : 88
Age : 34
Lokasi : Pontianak
Registration date : 11.12.08

Perintah VB Akses File Empty
PostSubyek: Perintah VB Akses File   Perintah VB Akses File Icon_minitime2009-04-23, 23:06

Perintah Untuk Menyimpan Data teks perbaris dalam bentuk sebuah file.
Contoh Nama File : Filecoba.txt
Lokasi : berada satu folder dengan projek

Code:
Dim NamaFile As String
Namafile = App.Path & "\Filecoba.txt"
Open NamaFile For Output As #1
  Print #1, "Baris pertama : Test Simpan File"
  Print #1, "Baris Kedua:"
Close #1

Perintah Untuk Menambahkan isi Data teks perbaris dalam sebuah file.
Contoh Nama File : Filecoba.txt
Lokasi : berada satu folder dengan projek

Code:
Dim NamaFile As String
Namafile = App.Path & "\Filecoba.txt"
Open NamaFile For Append As #1
  Print #1, "Baris Tambahan pertama"
  Print #1, "Baris tambahan kedua"
Close #1

Perintah Untuk Membaca isi Data teks hingga akhir baris pada sebuah file.
Contoh Nama File : Filecoba.txt
Lokasi : berada satu folder dengan projek

Code:

Dim namafile As String
Dim tmp As String

namafile = App.Path & "\Filecoba.txt"
Open namafile For Input As #1
  While Not EOF(1)
      Input #1, tmp
      text1.text = tmp '<---contoh ingin mengetahui hasil pembacaan file
  Wend
Close #1

Perintah Untuk Membaca isi Data pada sebuah file (dalam bentuk binary).
Contoh Nama File : Filecoba.txt
Lokasi : berada satu folder dengan projek
Code:

Dim namafile As String
Dim tmp As String
Dim UkuranFile As Long

namafile = App.Path & "\Filecoba.txt"
UkuranFile = filelen(namafile)
tmp = space(UkuranFile) 'berikan ruang kosong untuk variable string sebesar ukurang file
Open namafile For Binary Access Read As #1
  get #1, , tmp
Close #1

text1.text = tmp '<--- Contoh ingin menampilkan hasil pembacaan file yang disimpan di variable tmp
Kembali Ke Atas Go down
http://aobe.web44.net
amburadul_bath
Bocah Forum
Bocah Forum
amburadul_bath


Male
Jumlah posting : 30
Age : 36
Lokasi : PONTIANAQ CITY
Registration date : 11.02.09

Perintah VB Akses File Empty
PostSubyek: Re: Perintah VB Akses File   Perintah VB Akses File Icon_minitime2009-04-23, 23:16

cobe looookkk....
Kembali Ke Atas Go down
bubles
Pendatang Baru
Pendatang Baru
bubles


Jumlah posting : 2
Age : 34
Registration date : 29.03.12

Perintah VB Akses File Empty
PostSubyek: Re: Perintah VB Akses File   Perintah VB Akses File Icon_minitime2012-03-29, 10:28

gan ane punya script kayak gini ni buat mengahasilkan output berfotmat .txt :

Private Sub Command2_Click()

Dim NamaFile As String
Dim tmp As String

NamaFile = App.Path & “\File\” & Text3.Text & “.txt”
Open NamaFile For Append As #1
Print #1, “Data Baris pertama”
Print #1, “”
Print #1, “Data tambahan ketiga”

Close #1

NamaFile = App.Path & “\Filecoba.txt”
Open NamaFile For Input As #1
While Not EOF(1)
Input #1, tmp
Label1.Caption = tmp ‘<—contoh ingin mengetahui hasil pembacaan file
Wend
Close #1
End Sub

nah ane bingungnya gimana caranya nampilin data nya data baris pertama itu berasal dari query ini :

select sandi,jku,tgl_lapor,noform,jmlisi from header where tgl_lapor = '05/03/2012'

dan data baris ketiga berasal dari query ini :

select kode_komponen,nama_komponen,t,t01,t02,t03,t04,t05,t06,t07,t08,t09,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30 from isi i, komponen k, header h where k.kode_komponen = i.kode_komponen and h.tgl_lapor = i.tgl_lapor ang i.tgl_lapor = '05/03/2012'

mohon bantuannya gan…
Kembali Ke Atas Go down
Sponsored content





Perintah VB Akses File Empty
PostSubyek: Re: Perintah VB Akses File   Perintah VB Akses File Icon_minitime

Kembali Ke Atas Go down
 
Perintah VB Akses File
Kembali Ke Atas 
Halaman 1 dari 1

Permissions in this forum:Anda tidak dapat menjawab topik
 :: Programming :: Pemrograman Visual :: Visual Basic-
Navigasi: