|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Case Sensitive Comparisonit 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 "Elena" <El***@discussions.microsoft.com> schrieb I have no clue where you are comparing and I can not know what the values of > 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. the variables are. So, it's impossible to say from here. Armin 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 Show quoteHide quote "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 > > 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 Show quoteHide quote "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 > > > >
Show quote
Hide quote
"Elena" <El***@discussions.microsoft.com> schrieb I tried it and it says "False.":> 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 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 Ok, I removed the = True, but it's still not working. Any other suggestions?
Show quoteHide quote "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 > > > Ok, I removed the = True, but it's still not working. Any other Read the answer from Armin> suggestions? > Cor Show quoteHide quote > > > > "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 >> >> I did read it, and it's not working for me.
Show quoteHide quote "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 > >> > >> > > > 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 Show quoteHide quote "Elena" <El***@discussions.microsoft.com> schreef in bericht news:C6E0D052-992F-4D5A-9986-A7AD33D3EF16@microsoft.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 >> >> >> >> >> >> >> 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 Show quoteHide quote "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:C6E0D052-992F-4D5A-9986-A7AD33D3EF16@microsoft.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 > >> >> > >> >> > >> > >> > >> > > > "Elena" <El***@discussions.microsoft.com> schrieb Sorry, I don't understand. You mean Option Compare Text and Option Comapre > 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? Binary within the same file? I don't know, I've never used Option Compare Text. Armin "Elena" <El***@discussions.microsoft.com> schrieb: Did you try 'Option Compare Binary', 'StrCmp'/'String.Compare'?> 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. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> 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 Show quoteHide quote "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/> > >
Try Catch Else Finally
Select case wildcard user control dll missing DllRegisterServer Dropdownlist Chain Visible Accessing a Share Using Windows Credentials Vbnet 2005 and databases + database bug ?? About ListView1.Items.Contains Splitting filenames into parts Problem w/ special characters in a filestream Zip files using VB6 |
|||||||||||||||||||||||