Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

StringToReal


c0pYc@t ©   (2002-07-26 08:57:00) 

Подскажите как real"у присвоить стринг


Vlad1   (2002-07-28 15:18:00) [1]

И ещё для Delphi6:
r1:=StrToFloatDef(s,r2);

(если s невозможно преобразовать в real, то r1 станет равным r2)


Stranger71   (2002-07-26 14:50:00) [2]

А еще есть пережитки старого доброго Паскаля - процедура Val.

Кусок их делфишного хэлпа:
procedure Val(S; var V; var Code: Integer);

Description

Val converts the string value S to its numeric representation, as if it were read from a text file with Read.

S is a string-type expression; it must be a sequence of characters that form a signed real number.

V is an integer-type or real-type variable. If V is an integer-type variable, S must form a whole number.

Code is a variable of type Integer.

If the string is invalid, the index of the offending character is stored in Code; otherwise, Code is set to zero. For a null-terminated string, the error position returned in Code is one larger than the actual zero-based index of the character in error.


Alx2   (2002-07-26 12:57:00) [3]

>Robin (26.07.02 12:41)
Смайлик забыл, или это серьезно?


Robin   (2002-07-26 12:41:00) [4]

Может этот пример тебе поможет.

Function RealToStr(Value:real;n:integer):string;
var str1,str2:shortstring;
k,i,m:byte;
begin
str1:=FloatToStr(Value);
str2:=" ";
k:=1;
while (str1[k]<>",") and (k<length(str1)) do inc(k);
m:=n+k;
if m>length(str1) then m:=length(str1);
for i:=1 to m do str2[i]:=str1[i];
RealToStr:=Str2;
end;


Седой   (2002-07-26 10:21:00) [5]

Не занаю как Format а FloatToStrработает.Проверено


Седой   (2002-07-26 10:19:00) [6]

Не занаю как Format а StrToFloatработает.Проверено


c0pYc@t   (2002-07-26 09:04:00) [7]

Спасибо


Lord Warlock   (2002-07-26 09:02:00) [8]

StrToFloat или Format


MBo   (2002-07-26 09:01:00) [9]

ты когда-нибудь в хелп смотришь?


Наверх

Титульная страница Поиск, карта сайта Написать письмо