MACROMEDIA COLDFUSION MX 61-CFML Reference page 734

Cfml reference
Hide thumbs Also See for COLDFUSION MX 61-CFML:
Table of Contents

Advertisement

Val
Description
Converts numeric characters that occur at the beginning of a string to a number.
Returns
A number. If conversion fails, returns zero.
Category
Conversion
functions,
Function syntax
Val(string)
See also
IsNumeric
Parameters
Parameter
string
Usage
This function works as follows:
If
TestValue = "234A56?7'"
If
TestValue = "234'5678'9?'"
If
TestValue = "BG234"
If
TestValue = "0"
Example
<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">
<p>Enter a string, and determine whether 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>
734
Chapter 3: ColdFusion Functions
String functions
Description
A string or a variable that contains one
,
Val(TestValue)
,
,
Val(TestValue)
,
Val(TestValue)
returns 234
returns 234
Val(TestValue)
returns the value 0, (not an error)
returns the value 0, (not an error)

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents