Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 52,098 times

Contents

Related Categories

Mathematical Functions - Standard Math Functions

Standard Math Functions

Math Function Evaluates:

Less than?

<>

Not

>

Greater than?

+

Add

*

Multiply

()

Math Brackets

-

Subtract

^

Power of
/ Divide

You can use these as if you were using a calculator. The standard rule applies that division and multiplication are calculated before addition and subtraction, unless you use brackets. For example,

3 + 2 * 5 = 13   ' 2 multiplied by 5 is 10, then, add 3 which gives us 13
(3 + 2) * 5 = 25 ' 3 and 2 equals 5, and then multiply the 5 by 5, which gives us 25

The noticeable differences between a calculator and Visual Basic is that the signs used are slightly different. Look at the table below to see what I mean.

For example, the following code performs a number of functions on a number, and displays a message box with the result

' Multiply
Msgbox "Multiply 1 * 32: " & 1 * 32
' Divide
Msgbox "Divide 32 / 12: " & 32 / 12
' Power of 3
Msgbox "Power 9 ^ 3: " & 9 ^ 3
' Greater than 100?
Msgbox "234 greater than 100? " & 234 > 100

James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.

Comments

  • Re:Thanks.

    Posted by thargyaw on 02 Aug 2008

    Thanks for your advice.

  • Re: [66] Mathematical Functions

    Posted by asdfg on 06 Sep 2006

    if ur gettin incorrect ln() output then switch to radian mode or vice versa, which ever you are expecting.

  • Posted by coolgome2 on 04 May 2005

    If you're using the TI-89, the ln(x) function is the same as VB's log(x) function. If you want to use the ti-89's log(x) function in VB, you have to do log(x)/log(10). You should get the right answer.

  • Posted by chrisgbk on 04 Apr 2005

    the VB log function is the natural logarithm (base e), not a base 10 logarithm. the help files/MSDN have samples for making a base10 logarithm function... its something like:

    log(number)/log(e), wh...

  • VB Logarithm Error

    Posted by audio.mixer on 12 Mar 2005

    I am consistently getting problems with VB's logarithm function. In fact, on my TI-89, log(1.31) returns 0.11727..., not the number you gave, not 0.27... I am trying to write a program to calculate ga...