This works, but I know there must be a better way. Maybe using Type somehow?
B4X:
'-------------------------------------------------------------------------
'Returns 'a' or 'an' depending on if the passed string starts with a vowel.
'-------------------------------------------------------------------------
Sub DetermineAorAn (et As String) As String
If et.CharAt(0) = "a" OR et.CharAt(0) = "e" OR et.CharAt(0) = "i" OR _
et.CharAt(0) = "o" OR et.CharAt(0) = "u" OR et.CharAt(0) = "A" OR _
et.CharAt(0) = "E" OR et.CharAt(0) = "I" OR et.CharAt(0) = "O" OR _ et.CharAt(0) = "U" Then
Return "an "
Else
Return "a "
End If
End Sub
Thanks kiffi; your solution works. Although I'll have to give this more thought, as thedesolatesoul points out. There are so many exceptions in English, I doubt it would be possible to correctly resolve 'a' or 'an' all the time without the use of a huge database or something. At least I'll work on trying to get it right most of the time.