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 maximum luggage weight of the passengers at 100 pounds each:
'Retrieves the number of passengers from the edit box using the GetROProperty method
passenger = Browser ("Mercury_Tours").Page ("Find_Flights").WebEdit("numPassengers").GetROProperty("value")
'Multiplies the number of passengers by 100
weight = passenger * 100
'Inserts the maximum weight into a message box.
msgbox("The maximum weight for the party is "& weight &"pounds.")