Friday, October 5, 2018

4 digit PIN Style Login System

Hello Beautiful People,

Here I'm giving away the most unique way to login in excel based applications as 4 digit PIN style.

It's Fast and secured. And even with this post, you will receive the VBA Code to change the PIN No. by the authorized user.

So, What happened yesterday, my traditional login system, which has a username and password, as usual, has become more boring. I have just completed a development of an application for billing purpose and I was testing it and I felt, I should have something more fast and furious and secured way of login system. I was thinking of for the idea and suddenly my mom came to my room and asked me for my VISA debit card and she also asked me the PIN no. of the same card. But that leaves the fantastic idea on me.

I have quickly developed something very simple and sober which works exactly like what I have assumed. The user just needs to type 4 digit pin and without any control and by using of Textbox Change Event Mechanism, I get the best result out it. and it worked like a HERO!.

Now, I'm giving away the VBA code for the Userform and Module for Changing PIN No. on any time by the Authorized User.

Here are the things you need to prepare before placing of VBA Codes.

1. User form with only One TextBox and Designed it just like what you can see in the middle of the screenshot attached to this Post.



2. Place a Command Button anywhere you want and caption it as "Change PIN No."

3. Now Open the Userform and Double Click on the Textbox and put this code in it.

Private Sub TextBox1_Change()

Application.ScreenUpdating = False

Dim RealPass As Long
RealPass = THENEWGST.Sheets("REGISTRY").Range("Z1").Value
With LOGIN
If VBA.Len(.TextBox1.Value) = 4 Then
If VBA.Val(.TextBox1.Text) = VBA.Val(RealPass) Then
'Call here the next Procedure you want to execute after entering of successful PIN No. 
Else
MsgBox "Wrong PIN" & vbNewLine & vbNewLine & "Call us at 919328093207 for Any Query", vbExclamation, "Zyest Solutions"
.TextBox1.Value = vbNullString
End If
End If
End With

Application.ScreenUpdating = True

End Sub

4. Then Goto the button where you captioned it as "Change PIN No." and Put the following VBA Code in the Sub.

Private Sub PIN_CHANGING_PROCESS()

Application.ScreenUpdating = False

On Error Resume Next
Dim I As Variant
Dim J As Variant
Dim K As Variant
Dim L As Variant
L = THENEWGST.Sheets("REGISTRY").Range("Z1").Value

I = VBA.InputBox("Please Enter Your Current PIN", "PIN Changing Process")

If VBA.Val(I) = VBA.Val(L) Then
'/-------
J = VBA.InputBox("Please Enter Your NEW PIN", "PIN Changing Process")

If VBA.IsNumeric(J) = False Then
MsgBox "Only Numeric Inputs Are Allowed", vbExclamation, "Validation by Zyest Solutions"
Exit Sub
End If
If VBA.Len(J) <> 4 Then
MsgBox "Only Four [4] Digits are allowed as PIN", vbCritical, "Validation By Zyest Solutions"
Exit Sub
End If
'/-------
K = VBA.InputBox("Please Enter Your NEW PIN Again", "PIN Changing Process")

If VBA.IsNumeric(K) = False Then
MsgBox "Only Numeric Inputs Are Allowed", vbExclamation, "Validation by Zyest Solutions"
Exit Sub
End If
If VBA.Len(K) <> 4 Then
MsgBox "Only Four [4] Digits are allowed as PIN", vbCritical, "Validation By Zyest Solutions"
Exit Sub
End If
'/-------
If VBA.Val(J) = VBA.Val(K) Then
THENEWGST.Sheets("REGISTRY").Range("Z1").Value = VBA.Val(J)
MsgBox "Great! Your PIN No. is Changed!" & vbNewLine & vbNewLine & "Your New PIN No. is : " & J, vbOKOnly, "Zyest Solutions"
Else
MsgBox "PIN No. Doesn't matched, Please do it again", vbCritical, "Validation By Zyest"
End If
'/-------
Else
MsgBox "Wrong PIN No. Please Enter Correct PIN No.", vbExclamation, "Validation By Zyest Solutions"
End If

Exitit:

Application.ScreenUpdating = True

End Sub

Note: "THENEWGST" is my workbook name. So you can replace it with ThisWorkBook

So You can modify this code according to your requirements.

Enjoy it and try it. and leave your comments here. thanks.

Regards
Kamal Bharakhda
kamal.9328093207@gmail.com
+919328093207

IsValidPasswordString Function

'Following function will verify if the password string contains following characters or not? Rem : List of Characters Group - ASCII Rem ...