1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
Public Class Form1 'https://data.bls.gov/timeseries/CUURS49ASA0 'Example table in the LA, CA area Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim inflationRates As Dictionary(Of DateTime, Decimal) = New Dictionary(Of DateTime, Decimal) From { {New DateTime(2014, 1, 1), 242.434}, ' 2014 inflation rate {New DateTime(2015, 1, 1), 244.632}, ' 2015 inflation rate {New DateTime(2016, 1, 1), 249.246}, ' 2016 inflation rate {New DateTime(2016, 7, 1), 249.784}, ' 2016 inflation rate {New DateTime(2017, 1, 1), 256.21}, ' 2017 inflation rate {New DateTime(2018, 1, 1), 265.962}, ' 2018 inflation rate {New DateTime(2019, 1, 1), 274.114}, ' 2019 inflation rate {New DateTime(2020, 1, 1), 278.567}, ' 2020 inflation rate {New DateTime(2021, 1, 1), 289.244}, ' 2021 inflation rate {New DateTime(2022, 1, 1), 310.782}, ' 2022 inflation rate {New DateTime(2023, 1, 1), 321.583}, ' 2023 inflation rate {New DateTime(2024, 1, 1), 326.64}, ' 2024 inflation rate {New DateTime(2024, 6, 1), 332.357} } Dim startDate As DateTime = New DateTime(2016, 7, 1) Dim endDate As DateTime = New DateTime(2024, 6, 1) Dim realWage As Decimal = CalculateRealWage(30.0D, inflationRates, startDate, endDate, True) Dim realWageBackwards As Decimal = CalculateRealWage(50.0D, inflationRates, startDate, endDate, False) 'Console.WriteLine("Real Wage: " & realWage.ToString("C")) End Sub Function CalculateRealWage(ByVal initialWage As Decimal, ByVal inflationRates As Dictionary(Of DateTime, Decimal), ByVal startDate As DateTime, ByVal endDate As DateTime, ByVal ForwardOrBackwards As Boolean) As Decimal Dim startCPI As Decimal = inflationRates(startDate) Dim endCPI As Decimal = inflationRates(endDate) Dim RealWage As Decimal If ForwardOrBackwards Then RealWage = initialWage * (endCPI / startCPI) Debug.WriteLine("Ratio value: Using the startCPI of " & startCPI & " and " & endCPI & " creates a ratio of " & (1 / (startCPI / endCPI))) Debug.WriteLine("The amount of $" & initialWage & " in 2016 is worth " & RealWage.ToString("C") & " in todays money") Else 'Dim ReverseRealWage As Decimal = initialWage * (1 / (startCPI / endCPI)) RealWage = initialWage * (startCPI / endCPI) Debug.WriteLine("The amount of $" & initialWage & " dollars in todays money is was worth " & RealWage.ToString("C") & " back in " & startDate) End If Return RealWage End Function End Class |