Mega Code Archive

 
Categories / Delphi / Strings
 

Delphi - string ipuçları

Delphi -- String İpuçları 1. Editten sadece sayımı girilsin... :) procedure CheckText(Sender:TEdit; var Key:Char); begin If not (Key in ['0'..'9','.',#8, #13]) then Key := #0; If Key = '.' then begin If Pos('.', Sender.Text) > 0 then Key := #0; end; end; 2. Editin içini belli bir formatta yazdırmak... Procedure Format(MyEdit1,MyEdit2:TEdit); Var I : Integer; S : String; begin I := StrToInt(MyEdit1.Text); FmtStr(S, '%.3d', [I]); MyEdit2.Text := S; // I.E. If Edit1.Text := '1' den Edit2.Text := '001'; döndürür end; 3. String içinde belli iki karakter arasını almak... Function GetParsedItem(TheItemStr, ParseStr : String; ItemNum : Integer): String; Var I4 : Integer; S4 : String; Begin TheItemStr := TheItemStr + ParseStr; S4 := ''; I4 := 0; While I4 <= ItemNum Do Begin S4 := Copy(TheItemStr, 1, Pos(ParseStr, TheItemStr) - 1); Delete(TheItemStr, 1, Pos(ParseStr, TheItemStr)); Inc(I4); End; Result := S4; End; {TheItemStr de Parsestr ye bakiyor ve ItemNum inci parsestrden sonra tekrar bulana dek olan str yi veriyor.} 4.String şifreleme... function EnDeCode(const Value : String) : String; var CharIndex : Integer; ReturnValue : String; begin ReturnValue := ''; for CharIndex := 1 to Length(Value) do begin ReturnValue := ReturnValue + chr(NOT(ord(Value[CharIndex]))); end; Result := ReturnValue; end; --------------------------------------------------------------------------------