Search code examples
vbaarabic

How to test if a word is masculine or feminine in Arabic in VBA


How to test if a word is masculine or feminine in Arabic in VBA?

The word is a String.

Result should be True or False for masculine or feminine.

Example: "شمس" become feminine

"قمر" becomes masculine

This simple code does not work at all:

Sex = "M"
If Right(word, 1) = "ة" Then Sex = "F"

Thanks


Solution

  • If the only thing determining the gender of a word are its ending you can use select case (simple example for german):

    The number in Right() determines how many characters you want to look at.

    Public Function isMale(aWord As String) As Boolean
        Select Case True
            Case Right(aWord, 2) = "er"
                isMale = True
            Case Right(aWord, 2) = "in"
                isMale = False
            End Select
    End Function