<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../style.css">
<title>
Gambas Documentation - Val
</title>
</head>
<table class="none" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left">
<font size="-1">
<a href="../../help+en"><img class="flag" alt="Home" border="0" src="../../img/lang/en.png" align="center"></a>&nbsp;
<a href="../lang+en">Up</a>&nbsp;
<a href="until+en">Previous</a>&nbsp;
<a href="vardecl+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
Val
</h1>
<div class="black"><font size="-2"><b>Syntax</b></font></div>
<pre class="syntax"><u>Expression</u> <b>= Val (</b> <u>String</u> <b>)</b></pre><p>

Converts a string into a boolean, a number or a date, according to the content of the string.
<p>
<div class="warning"><table class="none" border="0"><tr><td width="40" valign="top"><img border="0" src="../../img/warning.png" align="center"></td><td valign="top">
The current localization is used to convert numbers and dates.
</td></tr></table></div>
<p>
The conversion algorithm is the following:
<p>
<ul>
<li>If the string can be interpreted as a date & time (with date or time separators), then the date & time is returned.
<li>Else, if the string can be interpreted as a floating point number, then this floating point number is returned.
<li>Else, if the string can be interpreted as a integer number, then this integer number is returned.
<li>Else, if the string is <tt>&quot;True&quot;</tt> or <tt>&quot;False&quot;</tt> , then the matching boolean value is returned.
<li>Otherwise, <a href="null+en">NULL</a> is returned.
<p>
</ul>

<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT Val(&quot;09/06/72 01:00&quot;)
<hr>09/06/72 01:00:00</pre>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT Val(&quot;3.1415&quot;)
<hr>3.1415</pre>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT Val(&quot;-25&quot;)
<hr>-25</pre>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT Val(&quot;True&quot;)
<hr>True</pre>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT IsNull(Val(&quot;Gambas&quot;))
<hr>True</pre>
<hr><b>See also</b><br>
<a href="../cat/conv+en">Conversion Functions</a>&nbsp;

</div>
</body>
</html>

