Results 1 to 7 of 7

Thread: Making the code compare strings case sensitive??

  1. #1
    Guest
    I have used this before but I cant remember exactly how I implement it...To make vb compare everything case sensitively.. For example

    If "kewl" = "Kewl" then
    msgbox "This wouldnt fire becuase they dont match in case."
    end if

    and using Lcase is not an option because im working on a code compiler and its case sensitive using same keys for same operation..For example in perl

    /u

    and

    /U

    are two different things...

    I thought it was something you put at the very top of your code like

    Option Case Sensitive..But that doesnt work..I know its one of those Option things tho..

  2. #2
    Addicted Member
    Join Date
    Aug 2000
    Posts
    208
    this is the way:
    after = Lcase( before ) 'Put before in LowerCase
    after = Ucase( before ) 'Put before in UpperCase


  3. #3
    Guest
    no I know about that already..I cant use that option because it wont work if you think about it. Plus that would be soooo slow on a 250 keyword list. that gets fired every few seconds..right now its fast very fast..

  4. #4
    Addicted Member
    Join Date
    Aug 2000
    Posts
    208
    you canot do that ?? :
    For CURRENTWORD = 0 to 250
    if Lcase(word1) = Lcase(word2) then
    'Welldone
    else
    'WORNG !!!!!
    end if
    next CURRENTWORD
    'FINISH

  5. #5
    Guest
    No I cant do that because I dont know if the word is going to be uppercase or lowercase...Also the word being compared is pulled out of a textfile and it needs to get compared against itself..

  6. #6
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    use Option Compare Text
    or is it Option Text Compare
    or
    Code:
    'StrComp function returns a number...0 if matched, 1 if false
    'compare strings to see if you have a matching string or not
    'if you use 1 as the comparison factor it 
    'forces a text comparison
    
    	strMyCompare = StrComp(string1, string2, 1) 'comparison function
         
    	If StrMyComp = 0 then  'true match          
         		'do bla bla bla because string1 = string2		'do bla bla bla
    	
    'or...	if false then
    	
    	Else
    		'do bla bla bla  because txtOne <> textTwo.text
    	End If



    [Edited by HeSaidJoe on 09-09-2000 at 11:11 PM]
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  7. #7
    Guest
    Joe thats what I was looking for.. Option Compare Text.. Thanks..I forgot what the command was for it lol..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width