Ir al contenido


Foto

[TRUCO DELPHI] Convertir el primer caracter de un Edit a Mayuscula


  • Por favor identifícate para responder
1 respuesta en este tema

#1 sir.dev.a.lot

sir.dev.a.lot

    Advanced Member

  • Miembros
  • PipPipPip
  • 545 mensajes
  • Location127.0.0.1

Escrito 28 noviembre 2016 - 02:35

[TRUCO DELPHI] Convertir el primer caracter de un Edit a Mayuscula


delphi
  1. with Sender as TEdit do
  2. if (SelStart = 0) or
  3. (Text[SelStart] = ' ') then
  4. if Key in ['a'..'z'] then
  5. Key := UpCase(Key);

Saludos!


  • 1

#2 sir.dev.a.lot

sir.dev.a.lot

    Advanced Member

  • Miembros
  • PipPipPip
  • 545 mensajes
  • Location127.0.0.1

Escrito 28 noviembre 2016 - 02:44

Segunda Version


delphi
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3. GetString : string;
  4. GetLength : Integer;
  5. I : Integer;
  6. T : String;
  7. begin
  8. if edit1.SelLength > 0 then
  9. GetString:= Edit1.Seltext
  10. else GetString:= Edit1.Text;
  11. GetLength:= Length(Edit1.Text);
  12. if GetLength>0 then begin
  13. for I:= 0 to GetLength do begin
  14. if (GetString[I] = ' ') or (I=0) then begin
  15. if GetString[I+1] in ['a'..'z'] then begin
  16. T:=GetString[I+1];
  17. T:=UpperCase(T);
  18. GetString[I+1]:=T[1];
  19. end;
  20. end;
  21. end;
  22. if edit1.Sellength>0 then
  23. Edit1.Seltext:=GetString
  24. else Edit1.Text:=GetString;
  25. end;
  26. end;


  • 1




IP.Board spam blocked by CleanTalk.