Results 1 to 3 of 3

Thread: Replacing String - Case not sensitive

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member Stiletto's Avatar
    Join Date
    Aug 2002
    Location
    Jerusalem, Israel
    Posts
    287

    Replacing String - Case not sensitive

    Hey,
    My code replaces a specific word chosen by the user by another word, also chosen by user. Lets say the words are And & &, and each time there "And", it will be replaced with &.
    The problem is that if the word is "and" (Lower Case), it wouldn't recognize it.
    How can I overcome this problem? What about the Compare Method?
    Code:
        sWords = Split(sData, vbNewLine)
        For i = LBound(sWords) To UBound(sWords) - 1
            'Retrive text to be replaced
            sText1 = Left(sWords(i), InStr(1, sWords(i), "=") - 1)
            If InStr(1, sFilename, sText1) Then
                'Replace sText1 with sText2
                sText2 = Right(sWords(i), (Len(sWords(i)) - InStr(1, sWords(i), "=")))
                sFilename = Replace(sFilename, sText1, sText2)
            End If
        Next i
        ConvertWords = sFilename
    Edit - totally forgot about LCase()...
    Last edited by Stiletto; Jul 19th, 2008 at 10:41 AM.

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