VB - Math

Hello, in this tutorial I would like to teach you something about the System.Math funtion and other mathemathical stuff that you can use in Visual Basic.

Start by creating a new windows form project and call it Math Functions.

Calculating PI:

Add a label and a textbox.

Double click the form and add the following codes to the form1_load event:

TextBox1.Text = System.Math.PI.ToString()

If you press F5 now or run your program, it will show the number PI in the textbox.

You can do a lot of things with the System.Math function. You can for example calculate the Sinus, Cos, Tan,...
The math function very much talks for itself if you know the real life math.
 

Simple calculations:

For this part of the tutorial, we want to calculate 340 + 45 and show the result in a messagebox.
To do this, simply add the following codes to the form1_load event:

MessageBox.Show(340 + 45)

You can put mathemathical forumlas into a messagebox, or if you would like to save the result, you could also put them into variables.

To store numbers into variables we have a few options but for this tutorial we will be using:
integers  =  Holds signed 32-bit (4-byte) integers that range in value from -2,147,483,648 through 2,147,483,647.
Doubles = Holds signed IEEE 64-bit (8-byte) double-precision floating-point numbers that range in value from -1.79769313486231570E+308 through -4.94065645841246544E-324 for negative values and from 4.94065645841246544E-324 through 1.79769313486231570E+308 for positive values. Double-precision numbers store an approximation of a real number.

Using integers:

        Dim intNumber1, intNumber2, intResult As Integer
        intNumber1 = 50
        intNumber2 = 90

        intResult = intNumber1 + intNumber2

        MessageBox.Show(intResult)

Using Doubles:

        Dim dblNumber1, dblNumber2, dblResult As Double
        dblNumber1 = 50
        dblNumber2 = 90

        dblResult = dblNumber1 / dblNumber2

        MessageBox.Show(dblResult)

 

For more information about diffrent number types, please click here

Download the source codes:
Math.rar (63 kB)


Topic: VB - Math

Date: 06/12/2013

By: greesyZer

Subject: TLPRMkef97



Reply

—————

Date: 02/12/2013

By: greesyZer

Subject: LVMHMmuw67



Reply

—————

Date: 02/12/2013

By: greesyZer

Subject: FZBRXlhu64



Reply

—————

Date: 01/12/2013

By: greesyZer

Subject: RPOMVgve15



Reply

—————

Date: 11/11/2013

By: greesyZer

Subject: ZGODIxpm70



Reply

—————

Date: 17/04/2013

By: Jacob Smith

Subject: LO

LOL HAx.12

Reply

—————

Date: 17/04/2013

By: Colin Black

Subject: Re: LO

WOW LOL YOU HAXER

Reply

—————

Date: 10/07/2012

By: Jay Bones

Subject: Lapa

Waley

Reply

—————