PC Review


Reply
Thread Tools Rate Thread

2 String values equal each other - Case Sensitive

 
 
Tony_VBACoder
Guest
Posts: n/a
 
      7th Jun 2004
In Access 2002 (SP2) with WinXP, I have 2 strings that I
am comparing when a user enters their password into a
LogIn form. The variables and their values are below:

' This is the password stored in the User's table
sPassword = "robert"
' This is the password the entered in the password text
box on the LogIn Form
sPasswordEntered = "ROBert"

When the following code is executed, I get a True result,
when in fact I should get a FALSE result:

If sPassword = sPasswordEntered Then
bSuccess = TRUE
Else
bSuccess = FALSE
End If

What is the best method to ensure that the user has
entered the correct password (case sensitivity does matter
here)?

 
Reply With Quote
 
 
 
 
Roger Carlson
Guest
Posts: n/a
 
      7th Jun 2004
Try the ASC function:

If Asc(sPassword) = Asc(sPasswordEntered) Then ...

--
--Roger Carlson
www.rogersaccesslibrary.com
Reply to: Roger dot Carlson at Spectrum-Health dot Org


"Tony_VBACoder" <(E-Mail Removed)> wrote in message
news:192e401c44ca3$2acdd810$(E-Mail Removed)...
> In Access 2002 (SP2) with WinXP, I have 2 strings that I
> am comparing when a user enters their password into a
> LogIn form. The variables and their values are below:
>
> ' This is the password stored in the User's table
> sPassword = "robert"
> ' This is the password the entered in the password text
> box on the LogIn Form
> sPasswordEntered = "ROBert"
>
> When the following code is executed, I get a True result,
> when in fact I should get a FALSE result:
>
> If sPassword = sPasswordEntered Then
> bSuccess = TRUE
> Else
> bSuccess = FALSE
> End If
>
> What is the best method to ensure that the user has
> entered the correct password (case sensitivity does matter
> here)?
>



 
Reply With Quote
 
solex
Guest
Posts: n/a
 
      7th Jun 2004
Add Option Compare Text to your module


"Tony_VBACoder" <(E-Mail Removed)> wrote in message
news:192e401c44ca3$2acdd810$(E-Mail Removed)...
> In Access 2002 (SP2) with WinXP, I have 2 strings that I
> am comparing when a user enters their password into a
> LogIn form. The variables and their values are below:
>
> ' This is the password stored in the User's table
> sPassword = "robert"
> ' This is the password the entered in the password text
> box on the LogIn Form
> sPasswordEntered = "ROBert"
>
> When the following code is executed, I get a True result,
> when in fact I should get a FALSE result:
>
> If sPassword = sPasswordEntered Then
> bSuccess = TRUE
> Else
> bSuccess = FALSE
> End If
>
> What is the best method to ensure that the user has
> entered the correct password (case sensitivity does matter
> here)?
>



 
Reply With Quote
 
solex
Guest
Posts: n/a
 
      7th Jun 2004
Sorry that should be Option Compare Binary, Option Compare Text will produce
the result you are current experiencing.


"solex" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Add Option Compare Text to your module
>
>
> "Tony_VBACoder" <(E-Mail Removed)> wrote in message
> news:192e401c44ca3$2acdd810$(E-Mail Removed)...
> > In Access 2002 (SP2) with WinXP, I have 2 strings that I
> > am comparing when a user enters their password into a
> > LogIn form. The variables and their values are below:
> >
> > ' This is the password stored in the User's table
> > sPassword = "robert"
> > ' This is the password the entered in the password text
> > box on the LogIn Form
> > sPasswordEntered = "ROBert"
> >
> > When the following code is executed, I get a True result,
> > when in fact I should get a FALSE result:
> >
> > If sPassword = sPasswordEntered Then
> > bSuccess = TRUE
> > Else
> > bSuccess = FALSE
> > End If
> >
> > What is the best method to ensure that the user has
> > entered the correct password (case sensitivity does matter
> > here)?
> >

>
>



 
Reply With Quote
 
Rick Brandt
Guest
Posts: n/a
 
      7th Jun 2004
"Roger Carlson" <NO-Rog3erc-(E-Mail Removed)> wrote in message
news:uKu$(E-Mail Removed)...
> Try the ASC function:
>
> If Asc(sPassword) = Asc(sPasswordEntered) Then ...


Asc() only evaluates the first character in a string though.


--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      7th Jun 2004
Tony_VBACoder wrote:

>In Access 2002 (SP2) with WinXP, I have 2 strings that I
>am comparing when a user enters their password into a
>LogIn form. The variables and their values are below:
>
>' This is the password stored in the User's table
>sPassword = "robert"
>' This is the password the entered in the password text
>box on the LogIn Form
>sPasswordEntered = "ROBert"
>
>When the following code is executed, I get a True result,
>when in fact I should get a FALSE result:
>
>If sPassword = sPasswordEntered Then
> bSuccess = TRUE
>Else
> bSuccess = FALSE
>End If
>
>What is the best method to ensure that the user has
>entered the correct password (case sensitivity does matter
>here)?



I like this way:

If StrComp(sPassword, sPasswordEntered, _
vbBinaryCompare) = 0 Then
bSuccess = TRUE
--
Marsh
MVP [MS Access]
 
Reply With Quote
 
Tony_VBACoder
Guest
Posts: n/a
 
      7th Jun 2004
Thanks.

StrComp worked the Best.


>-----Original Message-----
>Tony_VBACoder wrote:
>
>>In Access 2002 (SP2) with WinXP, I have 2 strings that I
>>am comparing when a user enters their password into a
>>LogIn form. The variables and their values are below:
>>
>>' This is the password stored in the User's table
>>sPassword = "robert"
>>' This is the password the entered in the password text
>>box on the LogIn Form
>>sPasswordEntered = "ROBert"
>>
>>When the following code is executed, I get a True

result,
>>when in fact I should get a FALSE result:
>>
>>If sPassword = sPasswordEntered Then
>> bSuccess = TRUE
>>Else
>> bSuccess = FALSE
>>End If
>>
>>What is the best method to ensure that the user has
>>entered the correct password (case sensitivity does

matter
>>here)?

>
>
>I like this way:
>
>If StrComp(sPassword, sPasswordEntered, _
>

vbBinaryCompare) = 0 Then
> bSuccess = TRUE
>--
>Marsh
>MVP [MS Access]
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking if a cell contains a string that is not case sensitive Colin Hempsey Microsoft Excel Programming 3 9th May 2008 05:41 PM
Are OL2007 rules that do string matches case sensitive? =?Utf-8?B?SVRmb3IyMA==?= Microsoft Outlook Discussion 0 31st May 2007 11:21 PM
string values do not equal cells, then return msg Kevin O'Neill Microsoft Excel Programming 2 14th Dec 2005 09:38 PM
Case Sensitive String Comparisons =?Utf-8?B?VGF0YWthdQ==?= Microsoft Access Form Coding 7 14th Oct 2005 05:40 PM
DropDownList values are case sensitive? Boban Dragojlovic Microsoft ASP .NET 1 7th Nov 2003 12:11 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:13 PM.