The following code is okey.
Sub Macro1()
Dim str As String
str = Sheets("Sheet1").Range("A1").Value
hasArabic (str)
End Sub
Function hasArabic(str As String) As Boolean
hasArabic = False
Dim i As Long
Dim c As Long
For i = 1 To Len(str)
c = AscW(Mid(String:=str, Start:=i, Length:=1))
If c >= &H600 And c <= &H6FF Then hasArabic = True: Exit For
Next i
End Function
I have tried to convert the above If Statement to Select Case Statement but the following code doesnt work.
Function hasArabic(str As String) As Boolean
hasArabic = False
Dim i As Long
Dim c As Long
For i = 1 To Len(str)
Select Case c = AscW(Mid(String:=str, Start:=i, Length:=1))
Case c >= &H600 And c <= &H6FF: hasArabic = True: Exit For
End Select
Next i
End Function
So please support me how to convert from If Statement to Select Case Statement.
The microsoft link:
>Solution :
Select Case is a poor choice if you only want to check one condition but:
Function hasArabic(str As String) As Boolean
Dim i As Long
For i = 1 To Len(str)
Select Case AscW(Mid(String:=str, Start:=i, Length:=1))
Case &H600 To &H6FF
hasArabic = True
Exit Function
End Select
Next i
End Function