1 / 5

Val Function

breck
Download Presentation

Val Function

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Val FunctionA Function performs anaction and returns a valueThe expression to operate upon, known as the argument, (or multiple arguments), must be enclosed in parenthesesVal an abbreviation for valueVal(ExpressionToConvert)The expression that is converted, can be the Property of a Control, a Variable, or a Constant

  2. The Val Function returns (produces) a value that can be used as a part of a statement, such as an assignment statementiQuantity = Val(txtQuantity.Text)The Val Function converts an argument to numeric, by beginning at the Left-Most CharacterIf that character is a numeric digit, decimal point, or sign, Val converts the character to numeric and moves to the next character. As soon as a non-numeric character is found, the operation stops

  3. Conversion FunctionThe Conversion Function checks if the value stored in the Property of a Control or a Variable is of a specific Data Type required in the execution of a statement(s), and if not the Conversion Function will return a ‘Run-Time Error’ Message The Text in Text Boxes is treated as a String, however in performing Arithmetic Operations (such as ^ * / + -), numeric values are required in the Text property of the Text Boxes

  4. VB Conversion FunctionsCInt - Converts a value to an Integer CLng - Converts a value to a Long Integer CSng - Converts a value to a Single Precision number CDbl - Converts a value to a Double Precision nember CCur - Converts a value to Currency CStr - Converts a value to a String CVar - Converts a value to a Variant

  5. CInt FunctionDim X As IntegerX = CInt(Text1.Text)Print XDim X As Integer, Y As IntegerY = CInt(X) * 2Print YCInt(“12”) the brackets are by default - 12CInt(“Twelve”) - ErrorCInt(Text1.Text) - the value of the Text in Text1, if it is valid

More Related