Val

Description

Returns a number that the beginning of a string can be converted to. Returns 0 if conversion is not possible.

Category

String functions

Syntax

Val(string) 

See also

IsNumeric

Parameters

Parameter
Description
string
A string

Example

<!--- This example shows Val --->
<html>
<head>
<title>
Val Example
</title>
</head>

<body bgcolor = silver>
<H3>Val Example</H3>
<cfif IsDefined("FORM.theTestValue")>
  <cfif Val(FORM.theTestValue) is not 0>
  <H3>The string <cfoutput>#DE(FORM.theTestValue)#</cfoutput> 
   can be converted to a number:
  <cfoutput>#Val(FORM.theTestValue)#</cfoutput></H3>
  <cfelse>
  <H3>The beginning of the string <cfoutput>#DE(FORM.theTestValue)#
   </cfoutput> cannot be converted to a number</H3>
  </cfif>
</cfif>

<form action = "val.cfm" method = "POST">
<P>Enter a string, and discover if
its beginning can be evaluated to a numeric value.

<P><input type = "Text" name = "TheTestValue" value = "123Boy">

<input type = "Submit" value = "Is the beginning numeric?" name = "">
</FORM>
</body>
</html>