Function ProperCaseEvaluate(sParam As String) As String
On Error Goto Erro
Dim vProperCase As Variant
vProperCase = Evaluate({@ProperCase("} & sParam & {")})
ProperCaseEvaluate = Cstr(vProperCase(0))
Exit Function
Erro:
ProperCaseEvaluate = ""
Exit Function
End Function
Function ProperCase(sParam As String) As String
On Error Goto Erro
Dim x As Integer
ProperCase = sParam
For x = 1 To Len(ProperCase)
If x = 1 Then
Mid$(ProperCase, 1, 1) = Ucase(Mid$(ProperCase, 1, 1))
Else
If Mid$( ProperCase, x - 1, 1 ) = " " Then
Mid$(ProperCase, x, 1) = Ucase$(Mid$( ProperCase, x, 1))
Else
Mid$(ProperCase, x, 1) = Lcase$(Mid$(ProperCase, x, 1))
End If
End If
Next
Exit Function
Erro:
ProperCase = ""
Exit Function
End Function
Nenhum comentário:
Postar um comentário