SHARE
TWEET

Untitled

a guest Sep 17th, 2019 105 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Buat koneksi ke .xls (Excel)
  2. strAlamat = D:\ImportDataa.xls 'Lokasi database Excel
  3. strKonek = "provider=microsoft.jet.oledb.4.0;"
  4. strKonek = strKonek & "data source=" & strAlamat & ";"
  5. strKonek = strKonek & "extended properties= 'Excel 8.0;HDR=yes;imex=0';"
  6. Conn.CursorLocation = adUseClient
  7. Conn.Open strKonek
  8.  
  9. 'Buka File Excel Sesuai Sesuai nama Sheetnya serta ditampilkan langsung ke listview
  10. Dim strKueri As String
  11. Set rsIdentitas = Nothing
  12. strKueri = "select * from [Sheet$]"
  13. rsIdentitas.Open strKueri, Conn, adOpenDynamic, adLockOptimistic
  14. If rsIdentitas.RecordCount > 0 Then
  15. rsIdentitas.MoveFirst
  16. ListView1.ListItems.Clear
  17. no = 0
  18. While Not rsIdentitas.EOF
  19. Set Lis = ListView1.ListItems.Add(, , no + 1)
  20.     Lis.SubItems(1) = rsIdentitas.Fields("Nama_Barang")
  21.     Lis.SubItems(2) = rsIdentitas.Fields("Harga_jual")
  22.     no = no + 1
  23. rsIdentitas.MoveNext
  24. Wend
  25.     Tb = no
  26.     'Lis.Selected
  27.     Lis.EnsureVisible 'posisi data paling bawah
  28. End If
  29. Conn.Close
  30. End Sub
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top