Visual Basic 2017 Built-In Functions

This year Microsoft introduced the latest version of Visual Basic, Visual Basic 2017.  It is included in the latest Visual Studio package, Visual Studio Community 2017.

Visual Basic 2017 includes numerous built-in functions to make programming jobs easier. These functions are categorized as follows:

  1. Mathematical functions
  2. Trigonometric Functions
  3. Format Functions

Of course, you can also create your own functions. Learn how to create your own functions in VB2017 from the following link

Visual Basic 2017 Lesson 17: Functions

 

 

Creating Financial Calculators

You can create all kinds of financial calculators in Visual Basic easily as long as long you know the relevant formulas.

For example, you can create a future value calculator using the following formula:

FV = PV * (1 + i / 100)n

FV=Future Value

PV=Present Value

i=Interest

n=Number of periods

You simply create a function for the future value, as follows:

Private Function FV(pv As Single, i As Single, n As Integer) As Double
FV = pv * (1 + i / 100) ^ n
End Function

You then write code for a button where it can compute the future value when the user clicks on the button, as follows:

Private Sub BtnCal_Click(sender As Object, e As EventArgs) Handles BtnCal.Click

Dim FutureVal As Single
Dim PresentVal As Single
Dim interest As Single
Dim period As Integer

PresentVal = TxtPV.Text
interest = TxtInt.Text
period = TxtN.Text
FutureVal = FV(PresentVal, interest, period)
LblFV.Text = Format(FutureVal, “$#,##0.00”)

End Sub

Some of the financial calculators created by us are:

Writing Maths and Science Programs

It is fairly easy to write maths and science programs in Visual Basic. Basically, it involves the use of arithmetic operators, mathematical expressions, functions, formulas, and equations. For example, Here are some examples:

Stock Trading Simulator

You can create a stock trading simulation program easily in Visual Basic. We will create such program using Visual Basic 6. Of course, you can also create the program using other versions of Visual Basic.

For stock trading, we need to consider the following data:

Asking Price- Price offered by the sellers
Bidding Price- Price offered by the buyers
Selling Quantity-Total number of shares available for sale on the stock market
Buying Quantity- Total number of shares the buyers bid on the stock market
Last Done Price- The price for the last transaction
Order Price – Price bid by the trader to buy or to sell
Order Quantity- Number of Shares ordered by the trader
Average Price- Average share price
Buy Value – Average value of shares paid by the trader
Gross Market Value- The current market of shares owned by the trader
The total number of shares in the hand of the trader.

Read more by following the link below:

Stock Trading Simulation Program

 

The IIf() Function

The IIf function denotes immediate decision function. It provides a simple decision-making process based on three arguments, as follows:

      IIf(x, y, z)

x represents a logical expression while y and z represent a numeric or a string expression.

For example, the IIF(x>y, expression 1, expression 2) function evaluates the values of x and y, if x>y. then expression 1 is true, otherwise, the expression 2 is true.

To learn more about the function and its application, follow the link below:

http://www.vbtutor.net/lesson7.html