Results 1 to 6 of 6
  1. #1
    Always_Learning is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    9

    Checking Password

    Hi There,

    Can someone help me with checking the characters of a password entered by the user.
    I need to check there is Uppercase characters, Lowercase Characters, Special Characters etc.



    I have tried the code below but it returns that all characters are lowercase when I have entered some uppercase characters.

    The Code I have used:

    Dim PasswordLength As Integer
    Dim AtChar As Byte
    Dim offset As Long
    Dim TempAlpha As String

    PasswordLength = Len(Me.Txt_Password)

    While PasswordLength <> AtChar ' Test value of Counter.
    AtChar = AtChar + 1 ' Increment Counter.
    TempAlpha = UCase(Mid(Me.Txt_Password, AtChar, 1))
    If UCase(Mid(Me.Txt_Password, AtChar, 1)) = True Then
    MsgBox ("Is UpperCase")
    Else
    MsgBox ("Is LowerCase")
    End If
    Wend ' End While loop.

    I would appreciate any help you can give.

    Best Regards,

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I would use the ASC standard to determine what characters the user is typing in. You could create a cheat sheet and store the cheat sheet as a table. Another approach would be to use built in functions.
    http://msdn.microsoft.com/en-us/libr...ffice.15).aspx

  3. #3
    drexasaurus's Avatar
    drexasaurus is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Location
    Santa Ana, CA
    Posts
    60
    UCase only returns the all upper-case version of the string, it doesn't test for case. You're testing if the upper-case letter = true, but that always = false. You could store the uppercase version of the character in a variable, and then test it against the original: you can use the StrComp function like this, StrComp("HE", "he", vbBinaryCompare) = 0, to test if there is a difference in case (the function will return 0 if they DO match, and <> 0 if they don't, it DOES NOT return true or false). Most other comparisons will compare capital and lowercase letters as the same.

    Dim upChar As String
    upChar = uCase(otherVariable)
    if StrComp(otherVariable, upChar, vbBinaryCompare) = 0 then
    debug.print "Is upper"
    else
    debug.print "Is lower"

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Another way to force case-sensitive comparisons, on a login form, is to use

    Option Compare Binary

    at the top of the code module for the form.

    Linq ;0)>
    Last edited by Missinglinq; 09-10-2014 at 04:51 PM.
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by Missinglinq View Post
    ...Option Compare Binary...
    And yet, people hate on Visual Basic. I find it extraordinarily versatile.

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Amen to that! Most people haven't a clue as to how powerful and complex a development language it really is!

    I used its predecessor, QuickBasic 4.5, for many years, developing databases, primarily, and I was amazed when I saw how much power the Boys of Redmond had added to it, not even counting the addition of Tripod, which was the basis for the GUI! I had an app that required the precise addition of a set number of days to given dates...30, 45. 60, 90, etc. To get it exact required determining the month of the original date, the number of days in that month, the number of days in the subsequent month(s,) whether or not it was a leap year or moving into a leap year, and so on. In QB 4.5 it took about 4 single-spaced pages of code. When I found out that in Visual Basic (and VBA, of course) those four pages of code could be replaced with

    Me.NewDate = DateAdd("d", 90, Me.OriginalDate)

    it just blew me away, and I was hooked!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 05-10-2014, 12:50 PM
  2. Replies: 2
    Last Post: 12-24-2012, 10:15 PM
  3. Replies: 1
    Last Post: 07-24-2012, 06:10 PM
  4. Replies: 1
    Last Post: 06-22-2012, 08:05 AM
  5. Change from old password to new password
    By richy in forum Security
    Replies: 0
    Last Post: 11-17-2005, 05:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums