Depreciation Calculator in Visual Basic

Obioku Obotette
3 min readOct 22, 2020

Option Strict On

Public Class frmDepreciation
‘Create Variables
Private intLifeSpan As Integer = 5I
Public Shared intArray As Integer = 7I
Public Shared strInventory(intArray) As String
Private strID(intArray) As String
Private decInitPrice(intArray) As Decimal
Private intQuantity(intArray) As Integer

Private Sub frmDepreciation_Load(sender As Object, e As EventArgs) Handles MyBase.Load
‘Initialize I/O file
Dim objReader As IO.StreamReader
Dim strFile As String = “H:\My Documents\Visual Studio 2012\Projects\Depreciation\inventory.txt”

‘Declare variables
Dim intCount As Integer = 0I
‘Dim intFill As Integer
Dim strError As String = “The file is not available. Restart when the file is available.”
Dim frmList As New frmDisplay

‘Verify file
If IO.File.Exists(strFile) Then
objReader = IO.File.OpenText(strFile)

‘Input file a line at a time
Do While objReader.Peek <> -1
‘shows message box when program begins and returns from second form

strInventory(intCount) = objReader.ReadLine()
strID(intCount) = objReader.ReadLine()
decInitPrice(intCount) = Convert.ToDecimal(objReader.ReadLine())
intQuantity(intCount) = Convert.ToInt32(objReader.ReadLine())
intCount += 1


Catch ex As IndexOutOfRangeException
MsgBox(“Array is out of bounds”, , “Range is not correct”)
End Try


‘Please inventory IDs in listbox
‘ For intFill = 0 To (strID.Length — 1)



Obioku Obotette

Trying to introduce myself in a new forum with hopeful expectations!