Calculations
Relevant for: GUI actions, scripted GUI components, and function libraries
You can write statements that perform simple calculations using mathematical operators. For example, you can use a multiplication operator to multiply the values displayed in two text boxes in your Web site. VBScript supports the following mathematical operators:
Operator |
Description |
---|---|
+ |
addition |
– |
subtraction |
– |
negation (a negative number) |
* |
multiplication |
/ |
division |
^ |
exponent |
In the following example, the multiplication operator is used to calculate the total price of three speakers:
'Retrieves the price of a speaker using the GetROProperty method
Price = Browser("Advantage Shopping").Page("Advantage Shopping").WebElement("$44.99").GetROProperty("innertext")
'Multiplies the price by 3
Total price = Price * 3
'Inserts the total price into a message box
msgbox("The total price is "& total price.")