NOTE:Make sure to add "StrUtils" to your Uses section
function properCase(sBuffer: string):string;
var
iLen, iIndex: integer;
begin
iLen := Length(sBuffer);
sBuffer:= Uppercase(MidStr(sBuffer, 1, 1)) + Lowercase(MidStr(sBuffer,2, iLen));
for iIndex := 0 to iLen do
begin
if MidStr(sBuffer, iIndex, 1) = ' ' then
sBuffer := MidStr(sBuffer, 0, iIndex) + Uppercase(MidStr(sBuffer, iIndex + 1, 1)) + Lowercase(MidStr(sBuffer, iIndex + 2, iLen));
end;
Result := sBuffer;
end;
|