Visual Basic Code For Simple Interest

Basic visual 6 basic data types. Application backgroundbasic data types are made by visualbasic 6 is provided to the reader's data type, and the reader is not required to re define a variable or constant that can be used directly.1 numeric data type2 character type data type3 logical data type4 date type data type5 enumerated data. Creating a real console application in Visual Basic! Although the Visual Basic compiler doesn't allow officially to create console applications, it's possible to do it with a simple trick. Read more Revealing the passwords behind asterisks This code snippet scans all opened windows, and reveals the passwords behind the password text-boxes.

Home > Articles > Programming > Windows Programming

How To Code In Visual Basic

  1. Sample Application: Calculating a Future Value
< BackPage 5 of 7Next >
This chapter is from the book
Sams Teach Yourself Visual Basic .NET in 21 Days

This chapter is from the book

This chapter is from the book

Sample Application: Calculating a Future Value

Now that you have explored creating and using variables and procedures, you can create an application that performs an investment calculation. This application will enable you to explore the lovely benefits of regular investing and compound interest. This sample Console application will avoid the complexity that a graphical user interface would add. Listing 3.4 shows the output from one run of the program.

Listing 3.4 The Investment Calculator

Visual Basic Codes For Excel

Here we see the result of starting with a $10,000 balance and adding $200 per month for 30 years, at a constant 5 percent interest.

The program requires the user to enter the four values (Initial Balance, Annual Interest, Monthly Deposit, and Years of Investment). In turn, the program calculates the final balance. This calculation is known as the Future Value (FV) calculation, and Visual Basic .NET includes it as one of its built-in functions. The formula for Future Value is

The following steps outline this procedure so that you can better understand how it works:

Visual basic codes pdfFor
  1. Begin by creating a new project in Visual Basic .NET. Select a new Visual Basic Console Application. Visual Basic .NET creates a new project with one module.

  2. Close the file window and rename the file using the Solution Explorer. Right-click on the filename Module1.vb in the Solution Explorer and select Rename. Change the filename to modInvest.vb.

  3. Change the name of the Startup Object, also. Right-click on the project in the Solution Explorer and select Properties. On the General page, change the Startup Object to Invest. This should be in the drop-down list.

  4. You're ready to begin coding. As a minimum, you need four variables to hold the user's input. Declare the variables as shown in Listing 3.5. Most of these values are floating point numbers, with the exception of Years. These declarations should occur between the Module line and the Sub Main() line because these will be Module-level variables.

  5. Listing 3.5 Declarations for the Future Value Calculation

  6. Use the Main routine to call each of the routines that will get the user input, do the calculations, and display the output, as in Listing 3.6.

  7. Listing 3.6 Main Routine

    In Listing 3.7, each of the major functions of the application is a separate subroutine or function. This enables you to more easily change the techniques for getting input or display output later.

  8. Add the code in Listing 3.7 to allow the user to enter information. The procedure does not take any parameters, nor does it return a value. Because this is a Console application, you'll use the Console.Read routine to get values.

  9. Listing 3.7 The Input Console.Read Routine

    Notice that the GetInputValues subroutine calls the GetValue function. This is an example of creating support routines. Rather than rewrite the code to prompt the user many times, pull the code out and create a procedure to perform the task. The resulting code in GetInputValues is therefore simplified.

  10. Write the routine that will display the output when it is calculated. Eventually, this might be displayed in a window, but for now, use the Console.WriteLine procedure, shown in Listing 3.8, to display the information. This procedure should take the value to display, and return nothing.

  11. Listing 3.8 The Output Console.WriteLine Routine

    This is a simple routine, consisting of a series of Console.WriteLine calls to display the entered values and the result of the calculation.

  12. Perform the FV calculation. This routine should take the four values as parameters, and return the result of the calculation. As it has a return value, this procedure is a function. Listing 3.9 shows the CalculateFV function.

  13. Listing 3.9 The CalculateFV Function

    Just as with the GetInputValues, you could have pulled out the code that calculated the decTemp value. However, because you only need this calculation in this routine, and likely won't need it again, you don't.

    Listing 3.10 shows the full code for the sample application.

    Listing 3.10 The Complete Investment Calculator

  14. Run the application. The output should be similar to that shown at the beginning of this section. You can run the application from the IDE by clicking the Play button on the toolbar. However, it is likely that the window that pops up with the application will go away too quickly for you to see the answer. Instead, run the program from the command prompt by running the executable created.

You can try a frightening experiment with this calculator. Enter deposit values representing the money you would normally spend on a vice (lunch at work, cigarettes, electronic gadgets) each month. The resulting Future Value can often be disturbing.

Related Resources

  • Book $31.99
  • eBook (Watermarked) $22.39
  • Book $96.32

How to write a visual basic program. Visual Basic programs for beginners with examples. How to print a string in visual basic. below are some examples of visual basic programs.

In this tutorial, Will see some basic string operation like how to print string and char in visual basic. Check thevisual basic program for mathematical operations.

Simple visual basic code

Let’s start with the basic “Hello World” Project in Visual basic. Start any programming language with some string operation is a really good idea.

Write a visual basic program to print a string “Hello World”

The below code will print the string value “Hello World”. Console.WriteLine(” “) is used to print any value as an output and the Console.ReadLine() is used to read the next line here we are using it to hold the screen.

Visual Basic Code For Simple Interest Inventory

Output: Hello World

Visual basic program to print a string variable.

Declare a variable in visual basic is really simple. here in the below code. Dim str As String is a variable decoration. Where str is a variable of string type.

Output: Write First Program in Visual basic

How to Concat two string in Visual basic.

+ or the & operator is used to Concat two or more string in Visual basic. Below is the code to Concat two string in visual basic. Which contains 3 strings str1, str2,str3.

Output: Visual basic program

Please check more examples on visual basic program for beginner

Visual Basic programs with example

Free visual basic code examples

Basic Vb programs

Example 2.1.1
Example 2.1.2

You can also use the + or the & operator to join two or more texts (string) together like in example 2.1.4 (a) and (b)

Example 2.1.4(a)

Private Sub

A = “Tom”
B = “likes”
C = “to”
D = “eat”
E = “burger”
Print A + B + C + D + E

End Sub

Example 2.1.4(b)

Private Sub

A = “Tom”
B = “likes”
C = “to”
D = “eat”
E = “burger”
Print A & B & C & D & E

End Sub

Write a VB program to convert Celsius to Fahrenheit

Java Program for Interview with example

Past Year’s Placement papers for Interview of MNC