Results 1 to 6 of 6

Thread: CPI inflation calculator

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2015

    CPI inflation calculator

    small but useful US CPI inflation routines converted from JS

    ' Tom's Inflation Calculator
    ' Copyright 2019, Tom R. Halfhill
    ' JavaScript version 3.14
    ' https://www.halfhill.com/inflation_js.html

    ' Dim xx As Double
    ' If cpi.calculate(100, 1980, 2018, xx) Then
    ' MsgBox xx
    ' Else
    ' MsgBox cpi.errMsg
    ' End If
    ' - or -
    ' MsgBox cpi.calculate_(100, 1980, 2018) '0 on error

    demo wrapper is a command line app which can run as console program or standard windows app

    'Usage: inf.exe dollars startYear [endYear=current] -d -c
    ' -d diff mode
    ' -c add commas
    'Example: inf.exe 160k 2006 -c

    misc note: if you want to run as a console app you can use the linktool or fastbuild addin's


    There are some others too or after compile just run

    link.exe /edit /subsystem:console <exePath>
    Attached Files Attached Files
    Last edited by dz32; Feb 8th, 2019 at 09:08 PM.

  2. #2
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Near Nashville TN

    Re: CPI inflation calculator

    Hi dz32,

    At first glance, I thought this was an amortization/depreciation routine, and that possibly some of the built-in VB6 financial functions would do the same thing. You almost never hear those financial functions mentioned (FV, PV, Rate, etc.).

    However, then I downloaded and took at look at the project. And you're actually using estimated inflation/deflation rates from 1667 through 2028, and that's sort of cool.

    I suppose I'll still make a couple of suggestions though: 1) It'd be cool if you'd develop a bit of a GUI, possibly with starting year and ending year (and starting year could be either earlier or later than ending year). That way, we could see the value of a dollar at any point (past or future) estimated at any other year (past or future).

    And 2) it seems that the CBO just estimates an inflation rate of 2.4% after 2023. I'm wondering why, for anything after 2023, you didn't just let it go on to infinity, using that 2.4% estimate for all future years.

    Those seem that they would be nice improvements to this interesting project.

    Take Care,

    EDIT1: Also, just as another idea, VB6 has the nice feature whereby you can dimension an array to any arbitrary range you want. As such, it might be nice if you dimmed your rates array as: Private rates(1666 to 2028) As Double. That would just be a bit more in the spirit of self-documenting code. And also, then you could use LBound() and UBound() to check for valid bounds. Just thinking out-loud.
    Last edited by Elroy; Feb 8th, 2019 at 09:37 AM.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2015

    Re: CPI inflation calculator

    there are a lot of interesting things it could be used for, I made it so I could wire the class into an app I am writing to explore house sale prices trying to gauge the market and current home prices

    I just did a quick direct port of the original JS those are good ideas for improvements. It does still show its js roots a bit. The original JS calculator actually has 5 or 6 different inflation calculations possible using different data sets that could also be ported over and included into this one.

    Outside of the main app I found I wanted to be able to just quickly run a calculation here and there, so I am compiling this to my windows directory as a console app so its really quick to fire up at anytime from a console window with the arguments i need without extra clicks.

    I have been meaning to find an amortization calculator too but haven't done it in vb yet would be great to find/create.

    If anyone wants to make improvements or upgrades on this run with it and feel free to post back to this thread.
    Its just a corollary to what i was working on and thought I would share.

    enjoy -dave
    Last edited by dz32; Feb 8th, 2019 at 07:32 PM.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2015

    Re: CPI inflation calculator

    also thanks for pointing me to the built in financial functions. started looking at those this morning and wow, after 20yrs I never even knew they existed lol. vb6 is a gift that keeps on giving

  5. #5
    Addicted Member
    Join Date
    Aug 2017

    Re: CPI inflation calculator

    Quote Originally Posted by dz32 View Post
    vb6 is a gift that keeps on giving
    Here's another one of VB6's well-kept secrets.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2015

    Re: CPI inflation calculator

    Agh that is a great find thanks for sharing. Trick digs up more awesome stuff lol

    Quote Originally Posted by Bonnie West
    The trick has shared an undocumented .VBP section tip that enables a Standard EXE project to be compiled as a console application (or standard DLL) without requiring post-processing of the EXE or use of IDE add-ins that hook into the build process:

    Last edited by dz32; Feb 12th, 2019 at 05:56 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width