|
-
Sep 9th, 2000, 09:53 AM
#1
Thread Starter
Addicted Member
I want to compare 2 string..
But if the string have uppercase un , that doesn't work..
exemple:
String1 to compare : welcome
String2 founded : Welcome
Code:
if String1 = String2 then
'allright
else
'nope
end if
how can I put the string2 and the string1 in lowercase ?
-
Sep 9th, 2000, 10:01 AM
#2
Frenzied Member
Code:
If Lcase(String1) = LCase(Sting2) Then...
'Will get them both in LowerCase
'Use UCase(String) for Uppercase
Hope it helped mate!
[Edited by Jop on 09-09-2000 at 11:05 AM]
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Sep 9th, 2000, 10:43 AM
#3
_______
<?>
Code:
'you can also just use the string compare function
Dim x As String, y As String
Dim myComp As String
x = "hello"
y = "HeLlO"
'if you use 1 as the 3rd argument it forces a text comparison
myComp = StrComp(x, y, 1) ' Returns 0 if matched.
If myComp = 0 Then
MsgBox myComp
End If
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 9th, 2000, 10:49 AM
#4
something else you should know, put this in your declarations section...
OPTION COMPARE TEXT
-
Sep 9th, 2000, 10:49 AM
#5
Frenzied Member
Let's be fair and keep it easy...
...wich one is faster? my code is shorter
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Sep 9th, 2000, 10:54 AM
#6
_______
<?>
myComp = StrComp(x, y, 1) ' Returns 0 if matched
not shorter that the line I gave if I didn't include the sample and besides we are not in a competition. we are supplying different avenues for the questioner to explore and learn.
The Option Explict is forced when the user enters the 3rd option 1 in the strCompare function.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 9th, 2000, 11:06 AM
#7
Frenzied Member
and besides we are not in a competition. we are supplying different avenues for the questioner to explore and learn.
I'm sorry if I made the impression to being competitive, maybe it was a kinda useless post, but I didn't see why we should use that code if you could do it in 1 line, but you're right, we should hive the questioners different solutions for their problem to let them deside to use what code to use.
Again, I'm sorry to make such a stupid reply, it wasn't meant to challenge you in any way.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|