Visual Basic Average Calculator

This tutorial we will show you how to create a Average Calculator written in Visual Basic. This application is created to calculate the average of the subjects and display on the screen. The application is very useful for the schools and colleges to calculate results of each students in each subjects. See example code below.

Sample Code

This script is for the function for displaying the splash screen and has a interval time to hide.
  1.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.         Me.Hide()
  3.         Dim frmSplash As New SplashScreen1
  4.         frmSplash.Show()
  5.         frmSplash.Update()
  6.         Threading.Thread.Sleep(3000)
  7.         frmSplash.Close()
  8.         Me.Visible = True
  9.  
  10.     End Sub
result
This script is for the function for the calculation of average by inputting the function together to the button and calling each name of textbox and adding together through the function of addition and division.
  1. Public Class Form1
  2.  
  3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4.         Dim intSubject1 As Integer = TextBox1.Text
  5.         Dim intSubject2 As Integer = TextBox2.Text
  6.         Dim intSubject3 As Integer = TextBox3.Text
  7.         Dim intSubject4 As Integer = TextBox4.Text
  8.         Dim intAnswer As Integer
  9.         Dim intAdd As Integer
  10.         intAdd = (intSubject1 + intSubject2 + intSubject3 + intSubject4) / 4
  11.         intAnswer = intAdd
  12.         Me.lblAnswer.Text = "Your Average Is = " & intAnswer
  13.     End Sub
  14.  
  15.     Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
  16.         Me.Close()
  17.     End Sub
  18. End Class
Hope that you learn from this tutorial and don't forget to Like & Share this project and the website. Enjoy Coding...!

Add new comment