hello can you please help me in my registration...my problem is that i don't know how to check if the user input numbers, character, and letters....i want that if the user inputed this in password,example password=jem125@# this will display in my lblvpass="Strong password",if the user input only jem125 it will display to the label "weak password"...can you please help me...hoping for your positive responds...here is my code

Option Explicit
Private con As ADODB.Connection
Private cmd As ADODB.Command
Private user_rs As ADODB.Recordset
Private sql As String, m_user As String


Private Sub Form_Load()
Set con = New ADODB.Connection
Set cmd = New ADODB.Command
Set user_rs = New ADODB.Recordset

With con
  .ConnectionString = "provider = microsoft.jet.oledb.4.0; data source =" & App.Path & "\password.mdb" & ";Persist Security Info=false;Jet OLEDB:Database Password=eldenz;"
  .Open
End With

Me.Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2

End Sub

Private Sub cmdreg_Click()

On Error GoTo cmdreg_Click

If txtRname.Text = "" Then
 MsgBox "PLEASE FILL UP THE EMPTY FIELD", vbCritical, "PLEASE FILL UP"
 Exit Sub
 End If

If txtRpass.Text = "" Then
 MsgBox "PLEASE FILL UP THE EMPTY FIELD", vbCritical, "PLEASE FILL UP"
 Exit Sub
 End If




m_user = Trim(txtRname.Text)



If Len(txtRpass.Text) <> Len(txtrepass.Text) Then

 MsgBox "SORRY PASSWORD DID NOT MATCH", vbCritical, "TRY AGAIN..."
 Exit Sub
 End If
 
 


If user_rs.State = adStateOpen Then
  user_rs.Close
  End If

sql = "select * from security where user_name ='" & m_user & "' "

user_rs.Open sql, con, adOpenDynamic, adLockOptimistic

If user_rs.BOF = True And user_rs.EOF = True Then

With user_rs
   
    .AddNew
    !user_name = Trim(txtRname.Text)
    !user_pass = Trim(txtRpass.Text)
    !rememberYesNo = "No"
    .Update
    .Close
    
End With

    
 MsgBox "Congratulations You Are Now Registered", vbInformation, "Successfully Registered"
 clear
Else

  MsgBox "USER NAME IS ALREADY EXIST", vbCritical, "PLEASE REGISTER AGAIN"
  clear
  Exit Sub
  
 End If
 
exit_cmdreg_Click:
 Exit Sub
 
 
cmdreg_Click:
  If Len(txtRname) > 6 Then
   MsgBox Err.Description, vbInformation, "Error on your USERNAME"
   Exit Sub
   End If
   
 If Len(txtRpass) > 6 Then
   MsgBox Err.Description, vbInformation, "Error on your PASSWORD"
   Exit Sub
   End If
   
 If Trim(txtRname) = "'" Then
  MsgBox Err.Description, vbExclamation, "THIS IS NOT ALLOWED"
  Exit Sub
  End If
End Sub


Private Sub clear()
 txtRname.Text = ""
 txtRpass.Text = ""
 txtrepass.Text = ""
 lblrepass.Caption = ""
End Sub



Private Sub lblvpass_Click()

End Sub

Private Sub txtrepass_Change()
If Trim(txtRpass.Text) = Trim(txtrepass.Text) Then

 lblrepass.Caption = "PASSWORD MATCH"
 lblrepass.FontBold = True
 lblrepass.FontItalic = False
 lblrepass.ForeColor = vbGreen
 
 Else
   lblrepass.Caption = "PASSWORD INVALID"
   lblrepass.FontItalic = True
   lblrepass.ForeColor = vbRed
 End If
 
End Sub

Private Sub txtrepass_Click()
txtrepass.Text = ""
lblrepass.Caption = ""
End Sub

Private Sub txtRname_Change()
lblvuser.Caption = ""
If Len(Trim(txtRname.Text)) > 6 Then
 lblvuser.Caption = "PLEASE USE 6 CHARACTERS ONLY.."
 End If
 
End Sub

Private Sub txtRname_Click()
lblvuser.Caption = ""

End Sub

Private Sub txtRpass_Change()
lblvpass.Caption = ""
If Len(txtRpass.Text) > 6 Then
 lblvpass.Caption = "PLEASE USE 6 CHARACTERS ONLY.."
 txtrepass.Enabled = True
 End If
End Sub

Private Sub txtRpass_Click()
lblvpass.Caption = ""
End Sub

Private Sub Label6_Click()
Form15.Show
Unload Me
End Sub

Private Sub cmdcancel_Click()
txtRname.Text = ""
txtRpass.Text = ""
txtrepass.Text = ""
lblrepass.Caption = ""
lblvuser.Caption = ""
lblvpass.Caption = ""
End Sub

Private Sub cmdexit_Click()
Unload Me
End Sub

Edited 6 Years Ago by jemz: n/a

Havoc, mayhem, problems, trouble, frustration, and broken keyboards, monitors, or other various items around your office/home and could include your knuckles...

Why? Because the pound character (#) is a wildcard character so if someone entered a password like...

123#

and someone else added a password like...

1234

or

1235

you would get all three... (Havoc!) and other characters you should watch out for (!*%) as they are also wildcard characters (not for all databases, but enough to cause you trouble, see your specific database documentation under wildcard characters for more information...)


There are many ways in which to verify a password, but what you were asking for, originally, was the strength of the password and being able to display a message...

Good Luck

Havoc, mayhem, problems, trouble, frustration, and broken keyboards, monitors, or other various items around your office/home and could include your knuckles...

Why? Because the pound character (#) is a wildcard character so if someone entered a password like...

123#

and someone else added a password like...

1234

or

1235

you would get all three... (Havoc!) and other characters you should watch out for (!*%) as they are also wildcard characters (not for all databases, but enough to cause you trouble, see your specific database documentation under wildcard characters for more information...)


There are many ways in which to verify a password, but what you were asking for, originally, was the strength of the password and being able to display a message...

Good Luck

hello sir thank you for the reply...sir i am confuse what will i do now sir inorder not to get havoc...im using MS access sir..Please help me sir hoping for your positive responds...

Restrict the user from entering those wildcard characters that you need to look up in M$ Access's help files in the keypress event, which I know you have seen before if you have been reading this forum...)

Good Luck

Hi Jemz,
I am sure your problem will be solved after using my below code.

Private Sub Text1_Change()
    Dim lt As String
    Dim intL As Integer
    intL = 0
    If Not Trim(Text1) = "" Then
          For i = 1 To Len(Text1)
              lt = Mid(Text1, i, 1)
              Select Case lt
                Case "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "<", ">", "?", "/", ":", "\", "=", ".", ","
                intL = intL + 1
              End Select
          Next i
        If intL >= 1 Then
        Label1.Caption = "Strong Password"
        Else
        Label1.Caption = "Weak Password"
        End If
    End If
End Sub

In my above example Text1 is your Password Textbox and Label1 will be your lblvpass which shows the strength of password.
My example code is based on number of Special Characters used.

Hope this helps

Edited 6 Years Ago by kinwang2009: n/a

Hi Jemz,
I am sure your problem will be solved after using my below code.

Private Sub Text1_Change()
    Dim lt As String
    Dim intL As Integer
    intL = 0
    If Not Trim(Text1) = "" Then
          For i = 1 To Len(Text1)
              lt = Mid(Text1, i, 1)
              Select Case lt
                Case "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "<", ">", "?", "/", ":", "\", "=", ".", ","
                intL = intL + 1
              End Select
          Next i
        If intL >= 1 Then
        Label1.Caption = "Strong Password"
        Else
        Label1.Caption = "Weak Password"
        End If
    End If
End Sub

In my above example Text1 is your Password Textbox and Label1 will be your lblvpass which shows the strength of password.
My example code is based on number of Special Characters used.

Hope this helps

hello sir thank you for the reply...i will write again if i have doubt...thank you again sir..more power to you..

Hi Jemz,
I am sure your problem will be solved after using my below code.

Private Sub Text1_Change()
    Dim lt As String
    Dim intL As Integer
    intL = 0
    If Not Trim(Text1) = "" Then
          For i = 1 To Len(Text1)
              lt = Mid(Text1, i, 1)
              Select Case lt
                Case "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "<", ">", "?", "/", ":", "\", "=", ".", ","
                intL = intL + 1
              End Select
          Next i
        If intL >= 1 Then
        Label1.Caption = "Strong Password"
        Else
        Label1.Caption = "Weak Password"
        End If
    End If
End Sub

In my above example Text1 is your Password Textbox and Label1 will be your lblvpass which shows the strength of password.
My example code is based on number of Special Characters used.

Hope this helps

hello sir thank you for helping me..i tried your code and it works sir,,but sir why is it if i input immediately this "*" it will display strong password...but i want to check sir if the user inputed this in the textbox example jem23&* so i want to be display strong password but it this only jem12 or jem this will display weak password because it should be combination of character,letter and number how can i check this sir if the user inputed this three?..please help me sir hoping for your positive.thank you in advance...

Hi Jemz,
I am sure your problem will be solved after using my below code.

Private Sub Text1_Change()
    Dim lt As String
    Dim intL As Integer
    intL = 0
    If Not Trim(Text1) = "" Then
          For i = 1 To Len(Text1)
              lt = Mid(Text1, i, 1)
              Select Case lt
                Case "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "<", ">", "?", "/", ":", "\", "=", ".", ","
                intL = intL + 1
              End Select
          Next i
        If intL >= 1 Then
        Label1.Caption = "Strong Password"
        Else
        Label1.Caption = "Weak Password"
        End If
    End If
End Sub

In my above example Text1 is your Password Textbox and Label1 will be your lblvpass which shows the strength of password.
My example code is based on number of Special Characters used.

Hope this helps

hello sir, i tried it and it works but i have problem why is it sir if i only input this "*" or "(" or other character it will display strong password..but sir i want the user to input combination of letter character and number that's the time to display strong password but if only number and character or number and letters it will display weak password...how do i check this sir please help me sir hoping for your positive responds...

Hi Jemz,
I have made little modification to my above code to meet your requirement. Check the below code.

Private Sub Text1_Change()
    Dim lt As String
    Dim intS As Integer
    Dim intL As Integer
    Dim intN As Integer
    
    intS = 0
    intN = 0
    intL = 0
    If Not Trim(Text1) = "" Then
          For i = 1 To Len(Text1)
              lt = Mid(Text1, i, 1)
              Select Case lt
                Case "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "-", "+", "|", "<", ">", "?", "/", ":", "\", "=", ".", ","
                intS = intS + 1
                Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
                intN = intN + 1
                Case "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
                intL = intL + 1
              End Select
          Next i
        If intS >= 1 And intN >= 1 And intL >= 1 Then
        Label1.Caption = "Strong Password"
        Else
        Label1.Caption = "Weak Password"
        End If
    End If
End Sub

Hope this will solve your problem.

Hi Jemz,
I have made little modification to my above code to meet your requirement. Check the below code.

Private Sub Text1_Change()
    Dim lt As String
    Dim intS As Integer
    Dim intL As Integer
    Dim intN As Integer
    
    intS = 0
    intN = 0
    intL = 0
    If Not Trim(Text1) = "" Then
          For i = 1 To Len(Text1)
              lt = Mid(Text1, i, 1)
              Select Case lt
                Case "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "-", "+", "|", "<", ">", "?", "/", ":", "\", "=", ".", ","
                intS = intS + 1
                Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
                intN = intN + 1
                Case "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
                intL = intL + 1
              End Select
          Next i
        If intS >= 1 And intN >= 1 And intL >= 1 Then
        Label1.Caption = "Strong Password"
        Else
        Label1.Caption = "Weak Password"
        End If
    End If
End Sub

Hope this will solve your problem.

hello sir it works thank you for helping me sir..sir can i ask? is it also possible to put this capslock is on?...example if the user already registered and now he will be going to login, then he will type username after that the password, but the txtbox of the password notify the user if his casplock is "ON" like what i have seen in some login credential programs...please help me sir hoping for your positive responds...thank you in advance...

Hi Jemz,
I got this code from internet when I was going through vb tutorials few years ago and it was really helpful. I am sure this will also solve your problem.

Option Explicit
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

Public Function CapsLockOn() As Boolean
    Dim iKeyState As Integer
    iKeyState = GetKeyState(vbKeyCapital)
    CapsLockOn = (iKeyState = 1 Or iKeyState = -127)
End Function

Private Sub txtPassword_GotFocus()
    If CapsLockOn = True Then
        MsgBox "Capslock is turned on!"
    Else
        MsgBox "Capslock is turned off!"
    End If

End Sub

Hope this helps

Hi Jemz,
I got this code from internet when I was going through vb tutorials few years ago and it was really helpful. I am sure this will also solve your problem.

Option Explicit
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

Public Function CapsLockOn() As Boolean
    Dim iKeyState As Integer
    iKeyState = GetKeyState(vbKeyCapital)
    CapsLockOn = (iKeyState = 1 Or iKeyState = -127)
End Function

Private Sub txtPassword_GotFocus()
    If CapsLockOn = True Then
        MsgBox "Capslock is turned on!"
    Else
        MsgBox "Capslock is turned off!"
    End If

End Sub

Hope this helps

hello sir thank you for helping me. sir, is that a message box in the textbox that say "your capslock is on"?...is there No other way sir not to use messagebox just like what i see in the other login program...or as what i have see from the internet website there login textbox...please help me sir hoping for your positive reponds...

Hi jemz,
Yea sure it is possible you can use text in Tag instead of msgbox. if you have problem about that let me know.
thankx

Hi jemz,
Yea sure it is possible you can use text in Tag instead of msgbox. if you have problem about that let me know.
thankx

hello sir thank you for the reply sir...i have not yet use text in tags sir...do i set this in the properties sir?please help me sir hoping for your positive responds...thank you in advance sir

Hi Jemz,
Apologize for replying late since i was on Official tour. I found out that it is better to use Label instead of ordinary message box. You can use Label.Caption to show status of CapsLock.
thankx

Hi Jemz,
Apologize for replying late since i was on Official tour. I found out that it is better to use Label instead of ordinary message box. You can use Label.Caption to show status of CapsLock.
thankx

hello sir,..okey sir i will just use the label for displaying the capslock is on message...

sir about the case "a","b" and etc...is there shortiest way on checking this letter sir?..hoping for your positive responds....thank you in advance...

Hi Jemz,
There is a short way to check letter "a", "b" etc and numbers by using KeyAscii in Keypress method. However this has drawbacks when you want to compare/check special characters like !@#$^ etc with numbers since these characters use Number Key in most of the standard keyboard.
Hope this is clear.

Edited 6 Years Ago by kinwang2009: n/a

Hi Jemz,
I think you didn't get my point. Anyway if you want to do in another way just go through this link. I have also learned a lot few years ago from this link. Hope this is helpful.
http://www.devx.com/vb2themax/Tip/19068
Good luck

hello sir,

sorry for the late reply, okay i will write again sir if i have doubt...thank you for giving me the link sir and helping me.....more power to you...

This question has already been answered. Start a new discussion instead.