VBScript Basics, Part 46 | Math Functions

preview_player
Показать описание
VBScripting (.vbs) Basic tutorial on how to use basic math functions such as addition, subtraction, multiplication, division, absolute value, getting rid of decimals, rounding off decimals, greater than, and less than signs, random numbers, etc...

Code Example: (Brackets are not allowed. Watch the video for the code on greater than and less than signs.)
___

a = 5
b = 3
c = 3

MsgBox a + b ,, "5 plus 3"
MsgBox a - c ,, "5 minus 3"
MsgBox b / a ,, "3 divided by 5"
MsgBox a * c ,, "5 times 3"

MsgBox Int(5.298723) ,, "Cuts off decimals of: 5.298723"
MsgBox Int(5.862987) ,, "Cuts off decimals of: 5.862987"

MsgBox Round(5.298723) ,, "Rounds off decimals of: 5.298723"
MsgBox Round(5.862987) ,, "Rounds off decimals of: 5.862987"

MsgBox Abs(-3) ,, "Absolute value of -3"

Randomize
MsgBox Int(10*Rnd) ,, "Random number between 0 and 10"
___
Рекомендации по теме
Комментарии
Автор

I forgot to mention 'Sqr(25)' would get the square root of 25 resulting in 5.

SimplyCoded
Автор

+ Works just like a &.
Here's a part of the script:
Anumber1=InputBox("Input first number", "")
Anumber2=InputBox("Input second number", "")
X=MsgBox (Anumber1+Anumber2)
Tell me if u want the full script :P

banananana
join shbcf.ru