473,386 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Case Sensitive Comparison

I'm trying to compare two pieces of text. If the cases are different, I want
it to be the same as if the text were different. I tried doing a binary
compare, but it's not working.

Does anyone have any suggestions? My code is below.

Thanks in Advanced,
Elena

Option Compare Binary

Imports System.Data.OleDb
Public Class CDRLValidation
Inherits System.Windows.Forms.Form
Dim strsql As String

'connection for debugging
Public Shared conStr As String = "Provider=Microsoft.JET.OLEDB.4.0;data
source=C:\CDRL.mdb"
' Create connection object
Public Shared conn As OleDbConnection = New OleDbConnection(conStr)

Private Sub CDRLValidation_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
Call Clearform()

End Sub
Private Sub Clearform()
TextBox1.Text = ""
TextBox2.Text = ""
' The password character is an asterisk.
TextBox2.PasswordChar = "*"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
strsql = "Select * from Login where user_name = '" & TextBox1.Text
& "' and user_pass = '" & TextBox2.Text & "'"
Debug.Write(strsql)
Dim cmd1 As New OleDbCommand(strsql, conn)
conn.Open()
Dim daUser As New OleDbDataAdapter(cmd1)
Dim dsUser As New DataSet
daUser.Fill(dsUser, "Login")
conn.Close()

Dim intCount As Integer = dsUser.Tables(0).Rows.Count
If intCount = 0 Then
MsgBox("User Name/Password does not exisist. Please, try again.")
Call Clearform()
End If
If intCount = 1 Then
Dim strChange As String =
dsUser.Tables(0).Rows(0)("user_pass").ToString
If strChange = "userPass" = True Then
Debug.Write(strChange)
Dim ChangePrompt As New ChangePrompt
ChangePrompt.ShowDialog()

Else
Dim CDRLSelect As New CDRLSelect
CDRLSelect.ShowDialog()
End If
End If

End Sub
End Class
Mar 17 '06 #1
12 1516
"Elena" <El***@discussions.microsoft.com> schrieb
I'm trying to compare two pieces of text. If the cases are
different, I want it to be the same as if the text were different.
I tried doing a binary compare, but it's not working.

Does anyone have any suggestions? My code is below.


I have no clue where you are comparing and I can not know what the values of
the variables are. So, it's impossible to say from here.
Armin

Mar 17 '06 #2
ok, let me change the code a little.

If strChange = "userPass" = True Then
msgbox("True.")
Else
msgbox("False.")
End if

let's pretend that strChange = USERPASS

So, i'm comparing USERPASS to userPass. The message box that pops up should
say "False." Unfortunately, it doesn't. It says true. So, I'd like to know
how to compare these two things and when the case is different that it reads
it as false.

Elena

"Armin Zingler" wrote:
"Elena" <El***@discussions.microsoft.com> schrieb
I'm trying to compare two pieces of text. If the cases are
different, I want it to be the same as if the text were different.
I tried doing a binary compare, but it's not working.

Does anyone have any suggestions? My code is below.


I have no clue where you are comparing and I can not know what the values of
the variables are. So, it's impossible to say from here.
Armin

Mar 17 '06 #3
You need to remove the part "= True" in your If statement, otherwise it
always returns true (because you intentionally set it to True).
So this should work as you expect:
If strChange = "userPass" Then
msgbox("True.")
Else
msgbox("False.")
End if

Hope this helps.
VHD50
"Elena" wrote:
ok, let me change the code a little.

If strChange = "userPass" = True Then
msgbox("True.")
Else
msgbox("False.")
End if

let's pretend that strChange = USERPASS

So, i'm comparing USERPASS to userPass. The message box that pops up should
say "False." Unfortunately, it doesn't. It says true. So, I'd like to know
how to compare these two things and when the case is different that it reads
it as false.

Elena

"Armin Zingler" wrote:
"Elena" <El***@discussions.microsoft.com> schrieb
I'm trying to compare two pieces of text. If the cases are
different, I want it to be the same as if the text were different.
I tried doing a binary compare, but it's not working.

Does anyone have any suggestions? My code is below.


I have no clue where you are comparing and I can not know what the values of
the variables are. So, it's impossible to say from here.
Armin

Mar 17 '06 #4
"Elena" <El***@discussions.microsoft.com> schrieb
ok, let me change the code a little.

If strChange = "userPass" = True Then
msgbox("True.")
Else
msgbox("False.")
End if

let's pretend that strChange = USERPASS

So, i'm comparing USERPASS to userPass. The message box that pops
up should say "False." Unfortunately, it doesn't. It says true.
So, I'd like to know how to compare these two things and when the
case is different that it reads it as false.

Elena

I tried it and it says "False.":

Dim strChange As String = "USERPASS"

If strChange = "userPass" = True Then
MsgBox("True.")
Else
MsgBox("False.")
End If
The "= True" is not necessary but it doesn't change anything in this case.
It's like saying "if it is true that it is true then".
Armin

Mar 17 '06 #5
Ok, I removed the = True, but it's still not working. Any other suggestions?


"Armin Zingler" wrote:
"Elena" <El***@discussions.microsoft.com> schrieb
ok, let me change the code a little.

If strChange = "userPass" = True Then
msgbox("True.")
Else
msgbox("False.")
End if

let's pretend that strChange = USERPASS

So, i'm comparing USERPASS to userPass. The message box that pops
up should say "False." Unfortunately, it doesn't. It says true.
So, I'd like to know how to compare these two things and when the
case is different that it reads it as false.

Elena

I tried it and it says "False.":

Dim strChange As String = "USERPASS"

If strChange = "userPass" = True Then
MsgBox("True.")
Else
MsgBox("False.")
End If
The "= True" is not necessary but it doesn't change anything in this case.
It's like saying "if it is true that it is true then".
Armin

Mar 17 '06 #6
> Ok, I removed the = True, but it's still not working. Any other
suggestions?
Read the answer from Armin

Cor


"Armin Zingler" wrote:
"Elena" <El***@discussions.microsoft.com> schrieb
> ok, let me change the code a little.
>
> If strChange = "userPass" = True Then
> msgbox("True.")
> Else
> msgbox("False.")
> End if
>
> let's pretend that strChange = USERPASS
>
> So, i'm comparing USERPASS to userPass. The message box that pops
> up should say "False." Unfortunately, it doesn't. It says true.
> So, I'd like to know how to compare these two things and when the
> case is different that it reads it as false.
>
> Elena

I tried it and it says "False.":

Dim strChange As String = "USERPASS"

If strChange = "userPass" = True Then
MsgBox("True.")
Else
MsgBox("False.")
End If
The "= True" is not necessary but it doesn't change anything in this
case.
It's like saying "if it is true that it is true then".
Armin

Mar 18 '06 #7
"Elena" <El***@discussions.microsoft.com> schrieb:
I'm trying to compare two pieces of text. If the cases are different, I
want
it to be the same as if the text were different. I tried doing a binary
compare, but it's not working.


Did you try 'Option Compare Binary', 'StrCmp'/'String.Compare'?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 18 '06 #8
It's set to Option Compar Binary, but I have not used the string.compare.
Let me see if I can figure out that code.

Thanks,
Elena

"Herfried K. Wagner [MVP]" wrote:
"Elena" <El***@discussions.microsoft.com> schrieb:
I'm trying to compare two pieces of text. If the cases are different, I
want
it to be the same as if the text were different. I tried doing a binary
compare, but it's not working.


Did you try 'Option Compare Binary', 'StrCmp'/'String.Compare'?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 20 '06 #9

I did read it, and it's not working for me.

"Cor Ligthert [MVP]" wrote:
Ok, I removed the = True, but it's still not working. Any other
suggestions?

Read the answer from Armin

Cor


"Armin Zingler" wrote:
"Elena" <El***@discussions.microsoft.com> schrieb
> ok, let me change the code a little.
>
> If strChange = "userPass" = True Then
> msgbox("True.")
> Else
> msgbox("False.")
> End if
>
> let's pretend that strChange = USERPASS
>
> So, i'm comparing USERPASS to userPass. The message box that pops
> up should say "False." Unfortunately, it doesn't. It says true.
> So, I'd like to know how to compare these two things and when the
> case is different that it reads it as false.
>
> Elena
I tried it and it says "False.":

Dim strChange As String = "USERPASS"

If strChange = "userPass" = True Then
MsgBox("True.")
Else
MsgBox("False.")
End If
The "= True" is not necessary but it doesn't change anything in this
case.
It's like saying "if it is true that it is true then".
Armin


Mar 20 '06 #10
Elena,

Can you make a simple project with only those simple statements in the form
load event of it.
Than if it does not work, show it to us

Cor
"Elena" <El***@discussions.microsoft.com> schreef in bericht
news:C6**********************************@microsof t.com...

I did read it, and it's not working for me.

"Cor Ligthert [MVP]" wrote:
> Ok, I removed the = True, but it's still not working. Any other
> suggestions?
>

Read the answer from Armin

Cor

>
>
>
> "Armin Zingler" wrote:
>
>> "Elena" <El***@discussions.microsoft.com> schrieb
>> > ok, let me change the code a little.
>> >
>> > If strChange = "userPass" = True Then
>> > msgbox("True.")
>> > Else
>> > msgbox("False.")
>> > End if
>> >
>> > let's pretend that strChange = USERPASS
>> >
>> > So, i'm comparing USERPASS to userPass. The message box that pops
>> > up should say "False." Unfortunately, it doesn't. It says true.
>> > So, I'd like to know how to compare these two things and when the
>> > case is different that it reads it as false.
>> >
>> > Elena
>>
>>
>> I tried it and it says "False.":
>>
>> Dim strChange As String = "USERPASS"
>>
>> If strChange = "userPass" = True Then
>> MsgBox("True.")
>> Else
>> MsgBox("False.")
>> End If
>>
>>
>> The "= True" is not necessary but it doesn't change anything in this
>> case.
>> It's like saying "if it is true that it is true then".
>>
>>
>> Armin
>>
>>


Mar 20 '06 #11
I figured out the problem. The binary compare works. You were right, Armin.
Yet, now I need to do a string comparison of the same two variables. Is it
possible to do a string and binary compare in the same form? If so, how do i
differentiate the two?
Thanks in Advance,
Elena
"Cor Ligthert [MVP]" wrote:
Elena,

Can you make a simple project with only those simple statements in the form
load event of it.
Than if it does not work, show it to us

Cor
"Elena" <El***@discussions.microsoft.com> schreef in bericht
news:C6**********************************@microsof t.com...

I did read it, and it's not working for me.

"Cor Ligthert [MVP]" wrote:
> Ok, I removed the = True, but it's still not working. Any other
> suggestions?
>
Read the answer from Armin

Cor
>
>
>
> "Armin Zingler" wrote:
>
>> "Elena" <El***@discussions.microsoft.com> schrieb
>> > ok, let me change the code a little.
>> >
>> > If strChange = "userPass" = True Then
>> > msgbox("True.")
>> > Else
>> > msgbox("False.")
>> > End if
>> >
>> > let's pretend that strChange = USERPASS
>> >
>> > So, i'm comparing USERPASS to userPass. The message box that pops
>> > up should say "False." Unfortunately, it doesn't. It says true.
>> > So, I'd like to know how to compare these two things and when the
>> > case is different that it reads it as false.
>> >
>> > Elena
>>
>>
>> I tried it and it says "False.":
>>
>> Dim strChange As String = "USERPASS"
>>
>> If strChange = "userPass" = True Then
>> MsgBox("True.")
>> Else
>> MsgBox("False.")
>> End If
>>
>>
>> The "= True" is not necessary but it doesn't change anything in this
>> case.
>> It's like saying "if it is true that it is true then".
>>
>>
>> Armin
>>
>>


Mar 20 '06 #12
"Elena" <El***@discussions.microsoft.com> schrieb
I figured out the problem. The binary compare works. You were
right, Armin. Yet, now I need to do a string comparison of the same
two variables. Is it possible to do a string and binary compare in
the same form? If so, how do i differentiate the two?

Sorry, I don't understand. You mean Option Compare Text and Option Comapre
Binary within the same file? I don't know, I've never used Option Compare
Text.

Armin

Mar 20 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: lkrubner | last post by:
If I make this query with MySql: SELECT * WHERE keyword='urbanism' is the comparison case insensitive? Will MySql return all rows where keyword equals both 'urbanism' and 'Urbanism'? I...
2
by: Matthew Louden | last post by:
I am using VBScript for ASP. The control value must be case sensitive? The following example should print the "fname" value, but if if I change "submit" back to "SUBMIT". Then it works fine. <%...
2
by: J. Muenchbourg | last post by:
I'm doing a few tests with simple .net scripts, and I noticed that I display the following error message at ErrMessage.Text if I don't enter "BLUE" in capital letters into my input textbox: ...
6
by: DW | last post by:
Greetings: I have a SQL 2000 database, in which about 1% of the records are in lower case. I need to make them UPPER CASE. Is there a function to determine and change the case of existing...
7
by: Jan Nielsen | last post by:
Hi all I am learning Asp.Net using Vb.net (VS 2002). I found the following example in a book: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
3
by: Adam J. Schaff | last post by:
Hello. I recently noticed that the Sort method of the .NET ArrayList class does not behave as I expected. I expect 'A' < '_' < 'a' (as per their ascii values) but what I got was the opposite....
4
by: nemo | last post by:
I've included a list of username/password combinations in the Web.Config file and I've a simple .aspx page with a username and password field for the users to log in. While the password field is...
1
by: benhoefer | last post by:
I have been searching around and have not been able to find any info on this. I have a unique situation where I need a case sensitive map: std::map<string, intimap; I need to be able to run a...
6
by: Derik | last post by:
Okay, I THINK this is a PHP question... I've been mucking with PHP for awhile now, but just recently I've been poking at some ajax stuff, and I ran into something confusing; my Queries were...
11
by: Rafe | last post by:
Hi, I'm working within an application (making a lot of wrappers), but the application is not case sensitive. For example, Typing obj.name, obj.Name, or even object.naMe is all fine (as far as...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.