intrinsic functions pre-coded functions used to improve developer productivity broad range of...
TRANSCRIPT
Intrinsic FunctionsPre-coded FunctionsUsed to improve developer productivityBroad Range of Activities
Math calculationsTime/Date functionsString formattingMany more
Intrinsic FunctionsFunctions ALWAYS return a value
You MUST do something with the value that is returnedRight hand side of an assignment statementPart of an Output Statement
Examples of Intrinsic FunctionsFunction Description Example Result
CDbl Returns a double if the item can be converted(can handle currency)
CDbl (“23.5”)CDbl (“$32.00”)CDbl (“hello”)
23.532Type Mismatch Error
Val Returns the numbers contained in the parenthesis(stops at 1st non numeric item)
Val (txtInput.text)Val (“$32.00”)Val (“hello”)
Number from textbox0 0
Str Converts a number to a String
Str (123) “123”
IsNumeric
Returns true if the items can be converted to a number
IsNumeric (“23.5”)IsNumeric (txtInput.text)IsNumeric(“hello”)
True
False
Int Returns the integer part of a number
Int (123.456) 123
Examples of Intrinsic FunctionsFunction Description Example Result
FormatNumber
Formats a number to a specified decimal point(default of 2)
FormatNumber (8765.4534)FormatNumber (8765.4534, 3)
8,765.458,765.453
FormatCurrency
Formats a number with a dollar sign & cents
FormatCurrency (76)FormatCurrency (245879.358)
$76.00$245,879.36
FormatPercent
Formats a number as a percent
FormatPercent (.784)FormatPercent (8.2)
78.40%820.00%
More Intrinsic FunctionsInputBox
Prompts the user for keyboard inputInput is returned to the program for processing
Syntax:Result = InputBox (prompt, [title])
Example:strInput = InputBox (“Enter Input”, “Input”) strName = InputBox (“What is your name”)
One More Intrinsic FunctionMsgBox
Displays a message in a dialog boxSyntax
MsgBox (prompt)Example:
MsgBox (“Hello World”)MsgBox (“The Result is “ & Result)
ExampleCreate an application that adds items to a
sales receipt one at a time using an input text box and a button. Each time the button is pressed, the new item price should be added to a list box control which acts as a receipt. The program should also contain output labels for subtotal, sales tax and total that should be updated when an item is added to the receipt. (Ensure that the prices are numeric and that the output is formatted to currency)
TOE ChartTASK OBJECT EVENT
Input Price Text Box, Label None
Display Receipt List Box None
Display Subtotal Label, Label None
Display Sales Tax Label, Label None
Display Total Label, Label None
Add Item to Receipt Button Click
Exit Button Click
Add to Receipt ButtonRead in Data from Text BoxConvert to Number
CDblVal
Input into ListBoxFormatted as Currency
Update Subtotal, Tax, Total & Displays