Sunday, 21 January 2018

Case sensitive passwords in VB 6

In this article I am going to show you how you can use case sensitive password in Visual Basic 6.0 with Microsoft Access. First of all create a form with two text boxes, two labels and two command buttons, a timer and a progress bar on a form as shown in image.
Now, open the code window of the form and write the following code on the click events of the buttons and on the timer1’s timer events.

 
Private Sub Command1_Click()  
 'On Error Resume Next  
 Timer1.Enabled = True  
 End Sub  
 Private Sub Command2_Click()  
 End  
 End Sub  
 Private Sub Timer1_Timer()  
 ProgressBar1.Value = ProgressBar1.Value + 1  
 If ProgressBar1.Value = 100 Then  
     On Error Resume Next  
     Timer1.Enabled = False  
     Connection  
      Set rs = New ADODB.Recordset  
 Qry = "SELECT Password FROM Login WHERE UserName = '" & Text1.Text & "'"  
 rs.Open Qry, Con, adOpenDynamic, adLockOptimistic  
 If Not rs.EOF Then  
   If rs(0) = Text2.Text Then  
     Me.Hide  
     mainform.Show  
     GoTo c  
   Else  
     MsgBox "Invalid Username or Password", vbInformation, "Login..."  
     GoTo p  
   End If  
 Else  
 If rs.RecordCount < 1 Then  
         If Text1.Text = "system" And Text2.Text = "Admin" Then  
         Me.Hide  
     mainform.Show  
     GoTo c  
     End If  
     End If  
 End If  
 Text1.SetFocus  
       If rs.RecordCount < 1 Then  
         If Text1.Text = "superuser" And Text2.Text = "password" Then  
           Text1.Text = ""  
           Text2.Text = ""  
           Text1.SetFocus  
            Me.Hide  
            mainform.Show  
            Exit Sub  
          End If  
       End If  
 c:  
     If Not rs.EOF Then  
         mainform.StatusBar1.Panels(3).Text = Text1.Text  
         rs.Close  
        Me.Hide  
        mainform.Show  
 p:  
     Text1.Text = ""  
     Text2.Text = ""  
     Text1.SetFocus  
     ProgressBar1.Value = 0  
       End If  
 End If  
 End Sub  
Finally press F5 to run the project.

VB6

0 comments:

Post a Comment

 

© 2018 Mastering Web Development: HTML, Bootstrap, PHP, ASP.NET & VB.NET Essentials - Designed by Mukund | Privacy Policy | Sitemap

About Me | Contact Me | Write For Us