Help with code to find and replace

aysam

New member
Joined
Nov 11, 2011
Messages
2
Reaction score
0
Points
0
Hi All
I'm new here and I hope you help me
I have a code to find a certain letter in Arabic and replace it with another letter
my code finds every letter ( أ , إ , آ ) and replace it with ( ا )
the problem is that the code replaces every letter in the text and what I need is to replace
the first letter only if it 's one of those assigned letters
Here's my code
Code:
Public Function changesearch(Mytxt) As String
Dim tempstr As String
tempstr = Trim(Mytxt)
    
     If tempstr Like "*[أاآإ]*" Then
         For b = 1 To Len(tempstr)
              If Mid(tempstr, b, 1) = "ا" Or Mid(tempstr, b, 1) = "إ" Or Mid(tempstr, b, 1) = "أ" Or Mid(tempstr, b, 1) = "آ" Then
               Mid(tempstr, b, 1) = "ا"
              Else
                 
              End If
          Next
           End If
changesearch = tempstr

End Function
any help 'd be highly appreciated
 
Oh
Finally I got it
Change the
Mid(tempstr,b,1) to Mid(tempstr,1,1)
It works as I hoped
anyway thanks
 
Hi Aysam,

Welcome to the forum, and thanks for posting that you found a solution. Hopefully next time we can be a bit more help to you. :)
 
Back
Top