str这个函数怎么用?(20分)

  • 主题发起人 主题发起人 duckbill
  • 开始时间 开始时间
D

duckbill

Unregistered / Unconfirmed
GUEST, unregistred user!
你可以Delphi的帮助.
 
Delphi的帮助里不是有例子吗[:(]
 
procedure Str(X [: Width [: Decimals ]]
var S);

Description

Str procedure X to a string representation according to the Width and Decimals formatting parameters. The effect is like a call to Write except the resulting string is stored in S instead of being written to a text file.

X is an integer-type or real-type expression. Width and Decimals are integer-type expressions. S is a string-type variable or a zero-based character array variable if extended syntax is enabled.

就是把一个整形或者实型转化为一个string
 
str跟format差不多(前者是过程,后者是函数),我认为format更好用!
如:
var S:string;
Str(5.8:7:2,S)
等价于format('%7.2f',[5.8]);
Str(5:7,S)
等价于format('%7d',[5]);
 
发现str和string有点区别
 
[blue]不解[/blue][:(]
 
多人接受答案了。
 
后退
顶部