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/

Saturday, 16 July 2016

How to Reset Forgot Password in Visual Basic 6 0/MS Access Login Applica...

How to Reset Forgot Password in Visual Basic 6 0/MS Access Login Application-Step by Step-Visual Basic 6.0 Database Tutorial.
In this tutorial, following features are discussed
First, I am using my earlier Login Application https://youtu.be/s-BU03egpWA 
*How to make database connectivity with access database for Reset Form.
* How to check the existing User of the application, Whether User credentials are available in the database or not. It gives message according to the availability user.
*How to verify or authenticate the user by entering the date of birth which is registered while registration of the account using Login System.
*Once Date of birth is verified with the database.it generates message accordingly showing Full name of the user and Reset Password option is available where you can enter your new password.
* if Date of Birth is not verified ,then You cannot see the Reset Password option on the form and not able to change the password anymore.
*When you see the password reset option, Here you have to provide New Password and retype to confirm the same password.
if New and confirm password matches with each other ,then you will be able to change the password by clicking Change Password button otherwise it gives warning msg:Password not matched.
*Once you successfully change the password, now you can Login into the system with your New Password.

For more information and Demo, Please watch the video and Note down each step.You can also make the same application without any error.
for more Visual Basic tutorials,please visit
Youtube Channel:https://www.youtube.com/user/sandydehrian
Computer Gyan Blog:http://selfcomputerlearning.blogspot.in/



Source Code :-
______________________________________

LOGIN FORM
_____________________________________

Private Sub cancelbtn_Click()
End
End Sub


Private Sub loginbtn_Click()
loginado.RecordSource = "select * from Logintb where Username='" + txtuser.Text + "' and Password='" + txtpass.Text + "'"
loginado.Refresh
If loginado.Recordset.EOF Then
MsgBox "Login failed,Try Again..!!!", vbCritical, "Please Enter correct Username and Password"
Else
MsgBox "Login Successful.", vbInformation, "Successful Attempt"
welcome.Show

End If
End Sub

Private Sub resetbtn_Click()
reset.Show
End Sub
_______________________________________

REGISTRATION FORM
_______________________________________

Private Sub Command1_Click()
registerado.Recordset.Fields("RollNo") = txtroll.Text
registerado.Recordset.Fields("Name") = txtname.Text
registerado.Recordset.Fields("Username") = txtuser.Text
registerado.Recordset.Fields("Password") = txtpass.Text
registerado.Recordset.Fields("DOB") = txtdob.Text
registerado.Recordset.Update
txtroll.Text = ""
txtname.Text = ""
txtuser.Text = ""
txtpass.Text = ""
txtdob.Text = ""
MsgBox "Registration Successful,Please Login with your Username and Password"
Login.Show

End Sub

Private Sub Form_Load()
registerado.Recordset.AddNew
End Sub
________________________________________

RESET FORM
________________________________________

Change Password code:-

Private Sub changepassbtn_Click()
If txtnew.Text = txtconfirm.Text Then
forgetado.Recordset.Fields("Password") = txtconfirm.Text
forgetado.Recordset.Update
MsgBox "Password Changed Successfully", vbInformation, "Password Change: Success"
reset.Hide
Login.Show
Else
MsgBox "Password Does not matched,Please Enter Correct Details", vbExclamation, "Change Password:Failed"
txtnew.Text = ""
txtconfirm.Text = ""
End If
End Sub

Check User code:-

Private Sub checkbtn_Click()
forgetado.RecordSource = "Select * from Logintb where username='" + txtuserid.Text + "'"
forgetado.Refresh
If forgetado.Recordset.EOF Then
lblmsg.Caption = "User ID Not Found ..Sorry Can't ReSet the password!!!! "
lblmsg.ForeColor = &HFF&
Else
lblmsg.Caption = "User ID Found in the database"
lblmsg.ForeColor = &H8000&
End If
End Sub

Form Load:-

Private Sub Form_Load()
txtnew.Visible = False
txtconfirm.Visible = False
changepassbtn.Visible = False
Label3.Visible = False
Label4.Visible = False
End Sub

Verification Code:-

Private Sub verifybtn_Click()
Dim str As String
str = StrComp(forgetado.Recordset.Fields("DOB").Value, txtdate.Text, vbTextCompare)
If str = True Then
lblmsg1.Caption = "Account not verified ,Can't reset the password"
lblmsg.Caption = "Sorry .. Date of Birth Not Matched !! "
lblmsg.ForeColor = &HFF&
lblmsg1.ForeColor = &HFF&
Else
lblmsg.ForeColor = &H8000&
lblmsg1.ForeColor = &H8000&
lblmsg.Caption = "Congratulations !!"
lblname.Caption = forgetado.Recordset.Fields("Name")
lblname.ForeColor = &HFF&
lblmsg1.Caption = "Account is verified Now,Set your new Password"
txtnew.Visible = True
txtconfirm.Visible = True
changepassbtn.Visible = True
Label3.Visible = True
Label4.Visible = True
End If
End Sub
__________________________________________

Option for Login or Registration
__________________________________________
Private Sub Command1_Click()
Registration.Show

End Sub

Private Sub Command2_Click()
Login.Show
End Sub
_________________________________________________________________________________
Please Share and Subscribe to my youtube channel.
Don't fogot to hit LIKE button if you like my work.

Sandeep Kaundal