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

contoh kode untuk membaca data dari exel

Go down

contoh kode untuk membaca data dari exel Empty contoh kode untuk membaca data dari exel

Post by sukma Fri 16 Jan 2009, 17:55

Private Sub GetColumns(ByVal Index As Integer)
Dim i As Integer

On Error GoTo ErrorhHandle
Dim rst As ADODB.Recordset
Dim rsC As ADODB.Recordset
Dim clm As ColumnHeader

Screen.MousePointer = vbHourglass

If Not gy_cnnXLS Is Nothing Then
If gy_cnnXLS.State > 0 Then
lsvRecordset.ListItems.Clear
lsvRecordset.ColumnHeaders.Clear

Set rst = gy_cnnXLS.OpenSchema(adSchemaTables)

If Not rst Is Nothing Then
If rst.State > 0 Then
If rst.RecordCount > 0 Then
For i = 0 To rst.RecordCount - 1
If Index = i Then

Set rsC =
gy_cnnXLS.OpenSchema(adSchemaColumns, Array(Empty, Empty,
Trim(rst.Fields("TABLE_NAME").Value & vbNullString), Empty))

If Not rsC Is Nothing Then

If rsC.State > 0
Then
txtColumn.Text = CStr(rsC.RecordCount)

If rsC.RecordCount > 0 Then

While Not rsC.EOF
Set clm = lsvRecordset.ColumnHeaders.Add
clm.Text = Trim(rsC.Fields("COLUMN_NAME").Value & vbNullString)
clm.Tag = "0"
If lsvRecordset.ColumnHeaders.Count = 1 Then
lsvRecordset.ColumnHeaders(1).Icon = (lsvRecordset.SortOrder + 1)
rsC.MoveNext
Wend

Set clm = Nothing

End If

rsC.Close

End If

Set rsC = Nothing
End If

Exit For
End If

rst.MoveNext
Next
End If

rst.Close
End If

Set rst = Nothing
End If
End If
End If

Screen.MousePointer = vbDefault
Exit Sub

ErrorhHandle:
MsgBox CutMSG(Err.Description)
End Sub

sumber http://vb-bego.net/forum/viewtopic.php?f=11&t=1302&start=0&st=0&sk=t&sd=a&sid=47453310b521ccb4d0a1812faa291425
sukma
sukma
Moderator
Moderator

Jumlah posting : 123
Age : 36
Lokasi : Magelang
Registration date : 23.05.08

http://www.masihbelajar.co.nr

Kembali Ke Atas Go down

Kembali Ke Atas

- Similar topics

 
Permissions in this forum:
Anda tidak dapat menjawab topik