×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

function val in fox pro

function val in fox pro

function val in fox pro

(OP)
how can i convert a string ch to float variable a use th function val(ch) but it return a numeric variable expl val(25.12) retrun 25 thanks for your help

RE: function val in fox pro

VAL(25.12) causes error 11.

In your locale, is the decimal point really a decimal point, or is it a comma?
VAL("25.12") returns 25.12, if SET("POINT") is "."

So VAL is respecting the locale format of numbers.

If you want your number to be evaluated as source code, always needing the point as the decimal point, then you may use EVAL(), though that opens a can of worms for strings not numeric. CAST("25.12" as double) will also work even with SET POINT TO ",". Needs VFP8 or 9, not sure. I'm just sure CAST() did not exist in VFP7 or earlier.

Just a side note: CAST is a very usual function or SQL clause for databases. It has a non-standard way of "parameterization" of initial value and target type separated with AS instead of a comma, so I don't consider it a normal function, but more of an SQL clause, just like BETWEEN has two parameters separated by an AND with a non-boolean meaning, so these things are rather the quirky nature I always attribute to the SQL language in it's aim to sound more natural than normal code. Still, CAST() is listed in the VFP help under Language Reference and the subtopic of Functions.

Bye, Olaf.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close