[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

There is not example on document 2005

Dear advisor !

I use Delphi 2005

I want know the example about using VAL function. But there is not example about this function. On document D2005, there is no any examlpe like D6, D7

So i should download document from www.borland.com

Is not example from document D2005 ? Example about Val and str funtion
0
namcit99
Asked:
namcit99
  • 3
  • 3
1 Solution
 
StevenBCommented:
To the best of my knowledge the Val function works the same in 2005 as it did in previous versions. The example from the D7 help file is:


uses Dialogs;
var

  I, Code: Integer;
begin
  { Get text from TEdit control }
  Val(Edit1.Text, I, Code);
  { Error during conversion to integer? }
  if Code <> 0 then
    MessageDlg('Error at position: ' + IntToStr(Code), mtWarning, [mbOk], 0, mbOk);
  else
    Canvas.TextOut(10, 10, 'Value = ' + IntToStr(I));

end;


Is that what you wanted?
0
 
namcit99Author Commented:

now, I already know to use about Val function. I complaint about document D2005. I want to read example , but nothing.
0
 
StevenBCommented:
So you actually want to find the complete 2005 documentation online? Sorry, I don't think it is available.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
namcit99Author Commented:

i am studying using Delphi. so i should use ducument so much when coding. IT is not suitablr for beginner with document D2005. because no example for function.
0
 
David_WardCommented:
Firstly, both "Val" and "Str" are procedures not functions.

Secondly, they are both very "old" and both have better modern alternatives.


Really, for "Val" you would be much better off using the "StrToIntDef" or "StrToInt64Def" functions, where you could do something like this;

MyIntVar:=StrToIntDef(MyNumberInStr,0);

with the added bonus of not needing to worry about numeric range limits or invalid characters in "MyNumberInStr" raising exceptions.


and for "Str" you would be better off using the "Format" function, like this;

MyNumberInStr:=Format(MyFormatStr,MyIntVar);

the "Format" function can deal with, pretty much, any kind of variable(s) in many ways, the "Format" function is very powerful and very flexible.


Cheers,

David.
0
 
StevenBCommented:
...although Val has the added functionality of returning the offending character position in the case of failure, which sets it apart from StrToIntDef or StrToInt.
0
 
namcit99Author Commented:

I consider on your idea
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now