Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String to Single ??

Status
Not open for further replies.

gforrest

Programmer
Apr 26, 2000
39
CA
Hi,

Does anyone know how to convert Singles to Strings and vice versa?
I'm looking for something like StrToInt or IntToStr type functions for the following code as I'm getting an error on the last line.

Thanks.

procedure TUSXchgFrm.FormActivate(Sender: TObject);
var
RecINFO : INFO;
rate : Single;

begin
read_options(@RecINFO); //read options file
rate := RecINFO.us_exch_rate; //read info from options file
CurUsXchgEdt.Text := rate; //assign value to Edit box

end;
 
1 Use a string variable in your form textvar
2 Use a single variable bitword
3 Use the procedure str Textvar <--- bitword
4 Assign Textvar to Editbutton.text

For the opposite use the val procedure after the OnExit event



Example
Code:
Type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;   
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  bitword : single;
  textvar : string;
implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
   bitword := 100.345;
   textvar := '';
   str(bitword:4:1,textvar);
   Edit1.Text := textvar;
end;
end.
S. van Els
SAvanEls@cq-link.sr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top