Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 11-09-2011
Nicolas_2011 Nicolas_2011 is offline
Miembro
NULL
 
Registrado: sep 2011
Posts: 59
Poder: 13
Nicolas_2011 Va por buen camino
conversion de sistema de numeracion + delphi 7

gente necesito ayuda, tengo todo el codigo, pero no puedo lograr unirlo en un solo radiogroup aca le va el codigo. lo que esta en azul supuestamente esta bien pero lo de rojo es el problema que tengo..espero q entiendan mi pequeño inconveniente de no ser asi explico mejor, espero su ayuda!!!
Código Delphi [-]
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    e: TEdit;
    rgbase: TRadioGroup;
    procedure eKeyPress(Sender: TObject; var Key: Char);
    procedure rgbaseClick(Sender: TObject);
  private
    Function dr (s:string; bl:integer):string; //base llegada
    Function sp (s:string ;bp:integer):string; // base partida
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
 Function TForm1.sp (s:string ;bp:integer):string; // suma ponderada
 var
  i:integer;
  m:Extended;
  Begin
  m:=0;
    For i:=1 to Length(s) do
      Case s[i] Of
        'A' : m:= m + 10* Power(bp,Length(s) - i);
        'B' : m:= m + 11* Power(bp,Length(s) - i);
        'C' : m:= m + 12* Power(bp,Length(s) - i);
        'D' : m:= m + 13* Power(bp,Length(s) - i);
        'E' : m:= m + 14* Power(bp,Length(s) - i);
        'F' : m:= m + 15* Power(bp,Length(s) - i);
          Else
            m:= m + StrToInt(s[i])*Power(bp,Length(s)-i);
            end;
    result:=FloatToStr(m);
end;
 Function TForm1.dr (s:string; bl:integer):string; // division reiterada
  Var
  num: integer;
  d:integer;
  resultado:string;
        Begin
        num:=StrToInt(s);
        resultado:=  ' ';
        while (num > 0) do
          begin
            d:= num mod bl;
            num:= num div bl;
                     case d of
              10: resultado:= 'A' + resultado;
              11: resultado:= 'B' + resultado;
              12: resultado:= 'C' + resultado;
              13: resultado:= 'D' + resultado;
              14: resultado:= 'E' + resultado;
              15: resultado:= 'F' + resultado;
                else
                  resultado:= IntToStr(d) + resultado;
              end;
              end;
              Result:=resultado;
            end;
{$R *.dfm}

procedure TForm1.eKeyPress(Sender: TObject; var Key: Char);   // restricciones
begin
  Case RgBase.ItemIndex Of
    0:Begin
    If not (Key in ['1','0', #8]) then
      key:= #0
end;
    1:Begin
    If not (Key in ['0'..'7', #8]) then
      key:= #0
end;
    2:Begin
    If not (Key in ['0'..'9', #8]) then
      key:= #0
end;
    3:Begin
    If not (Key in ['A'..'F', '0'..'9', #8]) then
      key:= #0
end;
end;

end;

procedure TForm1.rgbaseClick(Sender: TObject);  // conversion
begin
e.Enabled := true;
e.SetFocus;
 { ¡¡ AQUI EL PROBLEMA !! }
 Begin
  If rgbase.ItemIndex <> 2 then
    case rgbase.ItemIndex of
       0: e.Text := dr(e.Text,2);
       1: e.Text := dr(e.Text,8);
       2: e.Text := dr(e.Text,10);
       3: e.Text := dr(e.Text,16)
       Else
begin
If rgbase.ItemIndex = 2 then
  case rgbase.ItemIndex of
  0 : e.Text := sp(e.Text,2);
  1 : e.Text:= sp(e.Text,8);
  2 : e.Text:= sp(e.Text,10);
  3 : e.text:= sp(e.Text,16);
end;

end;


end;
end;
end;
end.
la idea es que seleccione un item y recien se habilite el edit cuando ingresa un numero hace click en otro item y cambia automaticamente el valor y asi sucesivamente.

Última edición por ecfisa fecha: 11-09-2011 a las 01:57:29. Razón: ETIQUETAS [DELPHI] [/DELPHI]
Responder Con Cita
 



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
Conversion de VB a Delphi jjmcira Varios 8 06-04-2011 14:51:23
Numeración de Factura zeta2 Varios 3 11-02-2010 20:21:56
Conversión de caracteres delphi 7 y 2009 ander Varios 0 03-12-2009 15:37:12
Conversion a delphi 6 mapc Varios 2 01-09-2006 14:27:56
Conversión de linea en Vbasic a Delphi torito Varios 4 09-06-2005 19:38:00


La franja horaria es GMT +2. Ahora son las 00:06:27.


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