by Dinesh Thakur Category: Variables and Constants

1. Visual Basic provides number of built in functions. The Val function is one of it. Val function converts the text data into a numeric value.

 

The general form of Val function is as follows:

Val(Expression to Convert)

 

2. The expression you wish to convert can be the property of control, a variable, or a constant.

 

3. A function can not stand by itself. It returns (produces) a value that can be used a part of a statement, such as the assignment statements in the following examples.

 

4. When the Val function converts as argument to numeric, it begins at argument’s left most character. If that character is a number digit, decimal point, or sign, Val converts the character to numeric and moves to the next character. As soon as a nonnumeric character is found, the operation stops.

 

5. Example: Val(123.45) will return = 123.45 and Val(123A5) will return 123 only.

 



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.