What will the function Val ($165.30) return?

  1. 165

  2. 165.3

  3. $165.30

  4. An error


Correct Option: D
Explanation:

The Val function in VBA is used to convert a string to a number. The string must contain only numeric characters, and the function will stop reading the string as soon as it encounters a non-numeric character.

In the case of Val($165.30)`, the function will encounter the dollar sign and the decimal point, which are not numeric characters. Therefore, the function will return an error.

Here is a table that summarizes the different options and their correctness:

Option Correctness Reason
A. 165 Incorrect The function will stop reading the string after the dollar sign.
B. 165.3 Incorrect The function will stop reading the string after the decimal point.
C. $165.30 Incorrect The function does not return the string itself. It returns the numeric value that the string represents.
D. Error Correct The function will encounter non-numeric characters and return an error.

Find more quizzes: