Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Pessoal, eu fiz uma função que gera o plural e singular de uma palavra.
Se o usuario informar "rações caninas", essa função deve mostrar "ração canina, rações caninas"
A função é essa. Não se espantem com a quantidade de if's:
Function Plural(Palavra) NewArray = Split(Palavra," ") For i = 0 to Ubound(NewArray) '"res" por "r" --- "controladores", "paladares" If Lcase(right(NewArray(i),4)) = "ores" or Lcase(right(NewArray(i),4)) = "ares" then 'response.write "1º caso" & "<br>" contador = len(NewArray(i))-2 str = str & " " & left(NewArray(i),contador) & " " & NewArray(i) Else '"is" por "l" --- "terminais", "incriveis", "paiois", "pauis" If Lcase(right(NewArray(i),3)) = "ais" or Lcase(right(NewArray(i),3)) = "eis" or Lcase(right(NewArray(i),3)) = "ois" or Lcase(right(NewArray(i),3)) = "uis" then 'response.write "2º caso" & "<br>" contador = len(newArray(i))-2 str = str & " " & mid(NewArray(i),1,contador) & "l" & " " & NewArray(i) Else '"aes" por "o" --- "caes" If Lcase(right(NewArray(i),3)) = "aes" then 'response.write "3º caso" & "<br>" contador = len(newArray(i))-2 str = str & " " & mid(NewArray(i),1,contador) & "o" & " " & NewArray(i) Else '"oes" por "ao" --- "botoes" If Lcase(right(NewArray(i),3)) = "oes" then 'response.write "4º caso" & "<br>" contador = len(newArray(i))-3 str = str & " " & mid(NewArray(i),1,contador) & "ao" & " " & NewArray(i) Else '"s" por "" --- "otimistas","leves","espertos","hindus" If (Lcase(right(NewArray(i),2)) = "as" or Lcase(right(NewArray(i),2)) = "es" or Lcase(right(NewArray(i),2)) = "os" or Lcase(right(NewArray(i),2)) = "us") and (len(NewArray(i)) > 5 or Lcase(right(NewArray(i),2)) <> "is" ) then 'response.write "5º caso" & "<br>" contador = len(newArray(i))-1 str = str & " " & left(NewArray(i),contador) & " " & NewArray(i) Else '"ns" por "m" --- "bons" If Lcase(right(NewArray(i),2)) = "ns" then 'response.write "6º caso" & "<br>" contador = len(newArray(i))-2 str = str & " " & mid(NewArray(i),1,contador) & "m" & " " & NewArray(i) Else '"uis" por "ul" ----- "azuis" If Lcase(right(NewArray(i),3)) = "uis" then 'response.write "7º caso" & "<br>" contador = len(newArray(i))-3 str = str & " " & mid(NewArray(i),1,contador) & "ul" & " " & NewArray(i) Else '"is" pr "i" ----- "barris","canis" If Lcase(right(NewArray(i),2)) = "is" and len(NewArray(i)) > 5 then 'response.write "8º caso" & "<br>" contador = len(newArray(i))-1 str = str & " " & mid(NewArray(i),1,contador) & "l" & " " & NewArray(i) Else 'response.write "último caso" & "<br>" str = str & " " & NewArray(i) End If End If End If End if End If End if end if End If Next Plural = Trim(str)End FunctionSó que ela me retorna "RAÇÃO RAÇÕES CANINA CANINAS", quando deveria retornar "ração canina, rações caninas"
Carregando comentários...