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; Function sp (s:string ;bp:integer):string;
public
end;
var
Form1: TForm1;
implementation
Function TForm1.sp (s:string ;bp:integer):string; 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; 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); 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); begin
e.Enabled := true;
e.SetFocus;
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.