Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 10-08-2015
Avatar de Casimiro Noteví
Casimiro Noteví Casimiro Noteví is online now
Merodeador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.669
Poder: 10
Casimiro Noteví Tiene un aura espectacularCasimiro Noteví Tiene un aura espectacular
Usa el ejemplo de jachguate.
Responder Con Cita
  #2  
Antiguo 11-08-2015
shoulder shoulder is offline
Miembro
 
Registrado: abr 2008
Posts: 441
Poder: 19
shoulder Va por buen camino
Mayuscula.

Código Delphi [-]
function Capitalize(Str: string): string;
var Index: Cardinal;
begin
 for Index := 1 to Length(Str) do
  if (Index = 1) or (Str[Index - 1] = ' ') then
   if Str[Index] in ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y',

    'z','á','é','í','ó','ú','ñ'] then
    Dec(Str[Index], 32) else
  else
   if Str[Index] in ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y',
   'Z','Á','É','Í','Ó','Ú','Ñ'] then
    Inc(Str[Index], 32);
 Result := Str;
end;
Responder Con Cita
  #3  
Antiguo 11-08-2015
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 38
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola.

Para sumar opciónes: Convertir un cadena donde cada Palabra Primera con mayuscula

Y una que contempla otros delimitadores ademas del espacio:
Código Delphi [-]
function UpperFirstChar(str: string): string;
const
  SEP = '|°!"#$%&/()={}[]¿?¡''''+*-_.,;:<> '; // (*)
var
  i : Integer;
begin
  Result := LowerCase(str);
  Result[1] := UpCase(Result[1]);
  for i := 1 to Length(Result) - 1 do
    if Pos(Result[i], sep) <> 0 then
      Result[i+1] := UpCase(Result[i+1]);
end;
(*) Caracteres que quieras considerar como separadores de palabra


Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita
  #4  
Antiguo 12-08-2015
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Poder: 23
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
TEN,

Cita:
Empezado por TEN
...como hago para que un label me ponga la primer letra de cada palabra en mayuscula...


Revisa este código:
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    Memo1: TMemo;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    function CapitalLetterText(Sender: TObject) : String;
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

const
  MsgUsr : String = 'test de primera letra en mayúsculas en cada palabra de un label, edit o memo';

var
  Form1: TForm1;

implementation

{$R *.dfm}

// Primera letra en mayúscula en cada palabra de un string
function CapitalLetterString(Value : String) : String;
var
   SL : TStringList;
   i : Integer;

begin
   SL := TStringList.Create;
   ExtractStrings([' '],[],PChar(Value),SL);
   for i := 0 to SL.Count - 1 do
      SL.Strings[i] := Uppercase(Copy(SL.Strings[i],1,1)) + Lowercase(Copy(SL.Strings[i],2,Length(SL.Strings[i])));
   SL.Delimiter := ' ';
   Result := SL.DelimitedText;
   SL.Free;
end;

// Primera letra en mayúscula en cada palabra de un label, edit o memo
function TForm1.CapitalLetterText(Sender : TObject) : String;
var
   SL1, SL2 : TStringList;
   i,j : Integer;
   AuxStr : String;

begin

   if (Sender is TEdit) then
      AuxStr := TEdit(Sender).Text;

   if (Sender is TLabel) then
      AuxStr := TLabel(Sender).Caption;

   if (Sender is TEdit) or (Sender is TLabel) then
   begin
      SL1 := TStringList.Create;
      ExtractStrings([' '],[],PChar(AuxStr),SL1);
      for i := 0 to SL1.Count - 1 do
         SL1.Strings[i] := Uppercase(Copy(SL1.Strings[i],1,1)) + Lowercase(Copy(SL1.Strings[i],2,Length(SL1.Strings[i])));
      SL1.Delimiter := ' ';
      Result := SL1.DelimitedText;
      SL1.Free;
   end;

   if (Sender is TMemo) then
   begin
      SL1 := TStringList.Create;
      SL2 := TStringList.Create;
      for i := 0 to TMemo(Sender).Lines.Count - 1 do
      begin
         AuxStr := TMemo(Sender).Lines.Strings[i];
         ExtractStrings([' '],[],PChar(AuxStr),SL1);
         for j := 0 to SL1.Count - 1 do
            SL1.Strings[j] := Uppercase(Copy(SL1.Strings[j],1,1)) + Lowercase(Copy(SL1.Strings[j],2,Length(SL1.Strings[j])));
         SL1.Delimiter := ' ';
         SL2.Add(SL1.DelimitedText);
         SL1.Clear;
      end;
      Result := SL2.Text;
      SL1.Free;
      SL2.Free;
   end;

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
   Label1.Caption := MsgUsr;
   Edit1.Text := MsgUsr;
   Memo1.Lines.Add('l1 ' + MsgUsr);
   Memo1.Lines.Add('l2 ' + MsgUsr);
end;

procedure TForm1.FormShow(Sender: TObject);
begin
   Button1.SetFocus;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   Label1.Caption := CapitalLetterText(Label1);
   Edit1.Text := CapitalLetterText(Edit1);
   Memo1.Lines.Text := CapitalLetterText(Memo1);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
   MessageDlg(CapitalLetterString(MsgUsr),mtInformation,[mbOK],0);
end;

end.
El código anterior en Delphi 7 sobre Windows 7 Professional x32, Permite poner en mayúscula la primera letra de cada palabra de un Edit, Label, Memo o String según se muestra en la siguiente imagen:



Espero sea útil

Nelson.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Primeras imágenes de Windows 8 Chris Noticias 7 08-06-2011 23:15:03
¿Como extraer de una cadena de 18 caracter, las primeras 10 letras? Nelly Varios 5 18-06-2007 20:00:09
Valor en letras, en mayuscula alcides Varios 15 09-03-2007 05:38:26
Primeras imágenes de Internet Explorer 7 marcoszorrilla Noticias 1 02-08-2005 03:54:16
Devolver Solo las Primeras N filas pzhero Oracle 1 21-08-2004 00:15:00


La franja horaria es GMT +2. Ahora son las 16:06:07.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi