Tuesday, 21 March 2017

Visual Basic 6.0 Tutorial | Search Records between Two dates using DataG...

Visual Basic 6.0 Tutorial | Search Records between Two dates using DataGrid and DTPicker Control
Visual Basic 6.0 Tutorial:Search Records between Two dates using DataGrid and Datepicker Control | Extract Records between two dates in Visual Basic 6.0 |Show Data between two dates-Visual Basic Database Application
In this video,following features are discussed:
1.How to add datepicker(DTpicker) control into the form.
2.How to format DTPicker Control and change the look of the control.
3.How to  make the necessary changes in the properties of DTPicker control for effecient data searching.
4.How to Extract records between Two dates using DTPicker Control.
for more Visual Basic tutorials,please visit
Youtube Channel:https://www.youtube.com/user/sandydehrian
Computer Gyan Blog:http://selfcomputerlearning.blogspot.in/

Monday, 19 December 2016

How to Connect Listview with Database and Load data into Listview-Step ...

Visual Basic 6.0 Tutorial :How to Connect Listview control with Microsoft  Access Database and  Load data into the Listview control-Step by Step Guide.
STEP:1
Create a Database Using Microsoft Access.
I have already created a database named"Logindataappmdb"and Table "Log".
STEP:2
1.Add ADO Library for database Connectivity
2. Add Listview Control onto VB Project.
STEP:3
Add ColumnHeaders to the Listview.
(For  Rollno,Name,Class,Section,Stream)
STEP:4
Create Objects for Database Connection and  Recordset in General Declaration Section

 
Code.
Dim connect As New ADODB.Connection
Dim rs As New ADODB.Recordset

Private Sub Form_Load()
With ListView1.ColumnHeaders
.Add , , "RollNo", Width / 5, lvwColumnLeft
.Add , , "Name", Width / 5, lvwColumnCenter
.Add , , "Class", Width / 5, lvwColumnCenter
.Add , , "Section", Width / 5, lvwColumnCenter
.Add , , "Stream", Width / 5, lvwColumnCenter
End With
loaddata
End Sub

Sub dbconnection()
connect.Open "Provider=Microsoft.jet.OLEDB.4.0;Data Source=D:\Database Folder\Logindataapp.mdb"
End Sub

Sub loaddata()
Dim list As ListItem
ListView1.ListItems.Clear
dbconnection
rs.Open "Select * from Log", connect, adOpenDynamic, adLockOptimistic
Do Until rs.EOF
Set list = ListView1.ListItems.Add(, , rs!RollNo)
list.SubItems(1) = rs!Name
list.SubItems(2) = rs!Class
list.SubItems(3) = rs!Section
list.SubItems(4) = rs!Stream
rs.MoveNext
Loop
End Sub

for more Visual Basic tutorials,please visit 
Youtube Channel:https://www.youtube.com/user/sandydehrian
Computer Gyan Blog:http://selfcomputerlearning.blogspot.in/

Sunday, 11 December 2016

Listview Control and Its Properties- Add,Delete Search and Sort Listview...

Listview and its properties-Add,Delete,Search and Sort Listitems in the Listview-Visual Basic 6-Quick and Easy
Working with Columnheaders (Add Column Headers,Add Images to Listview's CoumnHeaders ,Adjust ColumnHeader's Width,Align ColumnHeaders,Adding Images to columnHeaders)
Working with Listitems (Add Listitems,Add Images to Listitems of the Listview,Delete Listitems from Listview ,Seacrh Listitems in The Listview and Sort Listitems in Ascending or Descending Order)
STEP:1
 Add Listview Control and ImageList Control on to the form.
STEP-2
Set Properties of the Listview Control
and Add Images to the Imagelist Control.
(In ImageList,I am using index 1 Pic for ColumnHeader,Index 2 Pic for Male ,Index 3 Image for Female)
STEP:3
How to add Column Header to the List View.
A. Add Column Headers to the Listview
B. Align Columns Left,Right,Center
C. Adding Images to Column Headers using ImageList.
STEP:4
How to add Listitems to the Listview
A. Declare Listitem Object Variable.
B. Add Listitems to the Listview.
C. Add Images to the Listitem added to the Listview using ImageList.
STEP:5
How to Reorder Column Headers,Show/Hide ScrollBar, HoverSelection.
STEP:6
How to Select Full Row Listitem of the Listview.
STEP:6
For Delete and Search a particular Listitem from the Listview.
Add Command Buttons and Textbox Controls on to the form.
STEP:7
How to Delete Selected Listitem from ListView.
STEP:8
How to Search a Particular Listitem from Listview by highlighting that Item.
STEP:9
How to Sort Listitems in Ascending and Descending Order  in the Listview.
STEP:10
How to Change Background,Apply Font Size,Font Face,Font Style,Forecolor to Listview.




Code:
Delete Listems:
Private Sub Command1_Click()
ListView1.ListItems.Remove (ListView1.SelectedItem.Index)
End Sub

Find Listitem from the Listview:
Private Sub Command2_Click()
Dim itmx As ListItem
Set itmx = ListView1.FindItem(Text1.Text, lvwText, , lvwPartial)
If itmx Is Nothing Then
MsgBox "record not found", vbCritical
Else
ListView1.ListItems(itmx.Index).Selected = True
ListView1.SetFocus
End If
End Sub

Private Sub Form_Load()
Dim list As ListItem
Set ListView1.ColumnHeaderIcons = ImageList1
With ListView1.ColumnHeaders
.Add , , "RollNo", Width / 4, lvwColumnLeft, 1

.Add , , "Name", Width / 4, lvwColumnCenter, 1

.Add , , "Class", Width / 4, lvwColumnCenter, 1

.Add , , "Section", Width / 4, lvwColumnCenter, 1

End With
Set ListView1.SmallIcons = ImageList1
Set list = ListView1.ListItems.Add(, , "101", , 2)
list.SubItems(1) = "Sandeep Kaundal"
list.SubItems(2) = "MCA"
list.SubItems(3) = "A"
Set list = ListView1.ListItems.Add(, , "102", , 2)
list.SubItems(1) = "Ajay Kaundal"
list.SubItems(2) = "MBA"
list.SubItems(3) = "B"
Set list = ListView1.ListItems.Add(, , "103", , 3)
list.SubItems(1) = "Savita Kaundal"
list.SubItems(2) = "BCA"
list.SubItems(3) = "C"
Set list = ListView1.ListItems.Add(, , "104", , 2)
list.SubItems(1) = "Rajesh Kumar"
list.SubItems(2) = "MA"
list.SubItems(3) = "A"
Set list = ListView1.ListItems.Add(, , "105", , 2)
list.SubItems(1) = "Bhubnesh Kumar"
list.SubItems(2) = "MBA"
list.SubItems(3) = "C"
Set list = ListView1.ListItems.Add(, , "106", , 3)
list.SubItems(1) = "Kamlesh Kumari"
list.SubItems(2) = "BA"
list.SubItems(3) = "A"
ListView1.AllowColumnReorder = True
ListView1.FlatScrollBar = True
ListView1.HoverSelection = True
Set list = ListView1.ListItems.Add(, , "107", , 2)
list.SubItems(1) = "Dharmesh Kumar"
list.SubItems(2) = "MCA"
list.SubItems(3) = "B"

ListView1.TextBackground = lvwOpaque
ListView1.BackColor = vbYellow
ListView1.Font.Size = 15
ListView1.Font.Name = "Arial"
ListView1.ForeColor = vbBlue
ListView1.Font.Bold = True
End Sub

Sort Listitems in Ascending and Descending Order:
Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
ListView1.Sorted = True
If ListView1.SortOrder = lvwAscending Then
ListView1.SortOrder = lvwDescending
Else
ListView1.SortOrder = lvwAscending
End If
End Sub

for more Visual Basic tutorials,please visit
Youtube Channel:https://www.youtube.com/user/sandydehrian
Computer Gyan Blog:http://selfcomputerlearning.blogspot.in/