I this article I would like to share with you sample program written by my close friend, business partner and fellow software engineer Sir Larry Dave Emol a simple listview implementation in Microsoft Visual Basic 6 and Microsoft Access.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.
My personal website is http://www.jakerpomperada.com
Sample Program Output
Program Listing
MODULE DB CONNECTION
Option Explicit
Public MyConn As ADODB.Connection
Public rstUserAcct As ADODB.Recordset
Sub Main()
On Error Resume Next
Set MyConn = New ADODB.Connection
Set rstUserAcct = New ADODB.Recordset
MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & AppDir & "Tutorial.mdb;Persist Security Info=False;Jet OLEDB:Database Password =IT098"
MyConn.CursorLocation = adUseClient
'Start up object
Mainform.Show
End Sub
Public Function AppDir() As String
If Right$(App.Path, 1) = "\" Then
AppDir = App.Path
Else
AppDir = App.Path & "\"
End If
End Function
Private Sub Form_Activate()
data
End Sub
Sub data()
On Error Resume Next
Dim lst
Dim cnt As Integer
Dim X As Integer
Set rstUserAcct = New ADODB.Recordset
If rstUserAcct.State = 1 Then rstUserAcct.Close
rstUserAcct.Open "Select * from tblInfo", MyConn, adOpenDynamic, adLockBatchOptimistic
With Me.Listview1
.ColumnHeaders.Clear
.ListItems.Clear
.ColumnHeaders.Add , , "", 0
.ColumnHeaders.Add , , "USERNAME", 3000
.ColumnHeaders.Add , , "PASSWORD", 4000
.ColumnHeaders.Add , , "FISTNAME", 4000
.ColumnHeaders.Add , , "MIDDLENAME", 4000
.ColumnHeaders.Add , , "LASTNAME", 4000
End With
Do Until rstUserAcct.EOF
Set lst = Listview1.ListItems.Add(, , rstUserAcct.Fields!ID)
lst.ListSubItems.Add , , rstUserAcct.Fields!UserName
lst.ListSubItems.Add , , rstUserAcct.Fields!Password
lst.ListSubItems.Add , , rstUserAcct.Fields!firstname
lst.ListSubItems.Add , , rstUserAcct.Fields!middlename
lst.ListSubItems.Add , , rstUserAcct.Fields!lastname
cnt = cnt + 1
rstUserAcct.MoveNext
Loop
Label1.Caption = "Total No. of record(s): " & cnt
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
No comments:
Post a Comment