كيفية جعل الحرف الاول من كل كلمة حرف كبير
#3
تفضل اخي عبد المالك مع اني كنت اتمنى ان تقوم بمحاولة كما في السابق :
PHP كود :
function ConvertToCap(const ASource: string): string;
const
  
ACCEPTEDCHARS = ['a'..'z'];
var
  
i: Integer;
  
CapAll:Boolean; // Capitalize all 1st Chrs
begin
  CapAll 
:=True;
// Result:=ASource
  
Result := LowerCase(ASource);
  
// if Result<>'' then
  
if Result <> EmptyStr then
  
// Loop through all Chrs
    
for i := 1 to Length(Result) do
      if 
CapAll then begin   // Start Cap with a True Flag
        
Result[i] := UpCase(Result[I]); // hello world ---> Hello World
        
CapAll := False;
      
end else
      {* if 
you work Under Delphi 2009 >
      
then
      the following can be switched into 
:
      if 
NOT CharInSet(Result[i], ACCEPTEDCHARS) then
      
*}
      if 
Not (Result[i] In ACCEPTEDCHARS ) then
        CapAll 
:= True;
end; 

للتجريب :
PHP كود :
ShowMessage(ConvertToCap('mohammed abd el malek')); 

والسلام عليكم ورحمة الله وبركاته
الرد


الردود في هذا الموضوع
كيفية جعل الحرف الاول من كل كلمة حرف كبير - بواسطة mohfa - 29-04-2011, 11:37 AM

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم