Imports System.CodeDom Imports System.Collections.Concurrent Imports System.ComponentModel Imports System.Diagnostics.Eventing.Reader Imports System.Drawing.Drawing2D Imports System.IO Imports System.Runtime.Remoting Imports System.Runtime.Serialization Imports System.Security.Policy Imports System.Threading Imports System.Windows.Forms.DataVisualization.Charting Imports System.Windows.Forms.VisualStyles Imports System.Xml.Schema Imports Microsoft.VisualBasic.ApplicationServices Imports Microsoft.VisualBasic.Logging Imports Microsoft.Win32 Imports System.Runtime.InteropServices Public Class Form1 Public Sub whamo2() '## New substitute for whamo, started 30 Nov 2023 'Declare all or most of the variables here or in sub-units of code where needed 'calculate anyway cost and en eff cost and get PV cost, and energetishe Mehrkosten Dim totalCost, anywayCost, enEffCost, PVcost As Long '## Note: totalCost does not include PV costs If IsNumeric(txtTotalCost.Text) = False Then MsgBox("Please put only numbers in the text boxes") Else totalCost = Val(txtTotalCost.Text) anywayCost = Val(txtAnyway.Text) enEffCost = totalCost - anywayCost txtEnEffCost.Text = CStr(enEffCost) 'PVcost = Val(txtPVcost.Text) End If 'calculate the total amount to be borrowed, given the subsidies and own capital and including PV costs Dim ownCap, subSidies, amtBorrowed As Long ownCap = Val(txtOwnCap.Text) subSidies = Val(txtSubsidies.Text) amtBorrowed = enEffCost + PVcost - subSidies - ownCap txtBorrowed.Text = CStr(amtBorrowed) 'calculate the amount to be borrowed after the subsidised loan Dim subLoan, nonSubLoan As Long subLoan = Val(txtSubLoan.Text) nonSubLoan = amtBorrowed - subLoan txtNonSubLoan.Text = CStr(nonSubLoan) 'calculate the monthly loan repayments on the subsidised loan, if any Dim subIntRate, subIntRateMthly, discRate, discRateMthly As Double Dim npvSubLoanCosts, mthlySubLoanRepay, totSubLoanRepay, subLoanTerm As Long If subLoan > 0 Then subIntRate = Val(txtSubIntRate.Text) subLoanTerm = Val(txtSubLoanYrs.Text) subIntRateMthly = (1 + subIntRate / 100) ^ (1 / 12) - 1 '## note that subIntRateMthly is now in decimal form. mthlySubLoanRepay = (subIntRateMthly * subLoan * (1 + subIntRateMthly) ^ (subLoanTerm * 12)) / ((1 + subIntRateMthly) ^ (subLoanTerm * 12) - 1) txtSubLoanMthlyRepay.Text = CStr(mthlySubLoanRepay) totSubLoanRepay = mthlySubLoanRepay * subLoanTerm * 12 txtSubLoanTotRepay.Text = CStr(totSubLoanRepay) 'now work out NPV discRate = Val(txtDiscRate.Text) discRateMthly = (1 + discRate / 100) ^ (1 / 12) - 1 '## note that discRateMthly is now in decimal form. '## added 16 Feb2024 If discRate = subIntRate Then npvSubLoanCosts = subLoan Else npvSubLoanCosts = mthlySubLoanRepay * (1 - (1 / (1 + discRateMthly)) ^ (12 * subLoanTerm)) / (discRateMthly) End If txtNPVSubLoanRepayments.Text = CStr(npvSubLoanCosts) Else If subLoan = 0 Then mthlySubLoanRepay = 0 totSubLoanRepay = 0 npvSubLoanCosts = 0 txtSubLoanMthlyRepay.Text = CStr(mthlySubLoanRepay) txtSubLoanTotRepay.Text = CStr(totSubLoanRepay) txtNPVSubLoanRepayments.Text = CStr(npvSubLoanCosts) End If End If 'calculate the monthly loan repayments on the non-subsidised loan, given the interest rates and time span Dim oppCosts, npvTotCosts, mthlyLoanRepay, totLoanRepay, npvLoanRepay As Long Dim intRate, intRateMthly, loanTerm, oppCostTerm As Double '## New variable opp cost term intRate = Val(txtIntRate.Text) loanTerm = Val(txtLoanTerm.Text) intRateMthly = (1 + intRate / 100) ^ (1 / 12) - 1 '## note that intRateMthly is now in decimal form. 'now use the table mortgage formula for monthly payments mthlyLoanRepay = (intRateMthly * nonSubLoan * (1 + intRateMthly) ^ (loanTerm * 12)) / ((1 + intRateMthly) ^ (loanTerm * 12) - 1) txtLoanMthlyRepay.Text = CStr(mthlyLoanRepay) totLoanRepay = mthlyLoanRepay * loanTerm * 12 txtTotalRepay.Text = CStr(totLoanRepay) discRate = Val(txtDiscRate.Text) discRateMthly = (1 + discRate / 100) ^ (1 / 12) - 1 '## note that discRateMthly is now in decimal form 'now work out NPV '## added on 16 Feb 2024 If intRateMthly = discRateMthly Then npvLoanRepay = nonSubLoan Else npvLoanRepay = mthlyLoanRepay * (1 - (1 / (1 + discRateMthly)) ^ (12 * loanTerm)) / (discRateMthly) End If txtNPVLoan.Text = CStr(npvLoanRepay) 'calculate the opportunity costs Dim altInvIntRate, altIntRateMthly, mthlyOppCosts, altIntInvHzn As Double Dim npvOppCosts As Long altIntInvHzn = Val(txtAltInvHzn.Text) altInvIntRate = Val(txtOppInt.Text) altIntRateMthly = (1 + altInvIntRate / 100) ^ (1 / 12) - 1 '## note that altIntRateMthly is now in decimal form mthlyOppCosts = ownCap * altIntRateMthly 'now discount these to get the NPV of opportunity costs npvOppCosts = mthlyOppCosts * (1 - (1 / (1 + discRateMthly)) ^ (12 * altIntInvHzn)) / (discRateMthly) txtOppCosts.Text = CStr(npvOppCosts) 'add up the npvs of the four types of cost npvTotCosts = npvOppCosts + npvSubLoanCosts + npvLoanRepay + ownCap txtNPVTotCost.Text = CStr(npvTotCosts) txtTotCosts2.Text = CStr(npvTotCosts) 'calculate the monthly earnings from PV if any, and the NPV of these Dim pvEarnings, pvMthlyEarnings, pvLifetime As Double Dim npvPVEarnings, enPriceInfl, modDiscRate, modDiscRateMtly As Double pvEarnings = Val(txtPVannaulIncome.Text) pvLifetime = Val(txtPVLifetime.Text) pvMthlyEarnings = pvEarnings / 12 enPriceInfl = Val(txtEnPriceInfln.Text) modDiscRate = (1 + discRate / 100) / (1 + enPriceInfl / 100) modDiscRateMtly = modDiscRate ^ (1 / 12) - 1 '## so it's now in the form 0.00242 If modDiscRateMtly = 0 Then npvPVEarnings = pvMthlyEarnings * 12 * pvLifetime Else npvPVEarnings = pvMthlyEarnings * (1 - (1 / (1 + modDiscRateMtly)) ^ (12 * pvLifetime)) / (modDiscRateMtly) End If txtNPVPVEarnings.Text = Math.Round(npvPVEarnings, 0) 'calcuate energy saved (kWh/m2/y) Dim preRetCons, postRetCons, pvProdn, enSaved As Double preRetCons = Val(txtPreRetCons.Text) postRetCons = Val(txtPostRetCons.Text) enSaved = preRetCons - postRetCons txtEnSaved.Text = CStr(enSaved) 'Calculate the energy saved over the lifetime of the measures Dim mthlyEnCostSave, enPricePre, enPricePost, floorArea, enCostPrePMth, enCostPostPMth, PVIncome As Double PVIncome = Val(txtPVannaulIncome.Text) pvProdn = Val(txtPVProdn.Text) floorArea = Val(txtFloorArea.Text) enPricePre = Val(txtEnCost.Text) enPricePost = Val(txtEnCostPost.Text) enCostPrePMth = preRetCons * enPricePre * floorArea / 12 enCostPostPMth = postRetCons * enPricePost * floorArea / 12 mthlyEnCostSave = enCostPrePMth - enCostPostPMth + PVIncome / 12 'added the PV income here, 29July2023 'mthlyEnCostSave = enSaved * floorArea * enPrice / 12 txtEnCostSav.Text = Math.Round(mthlyEnCostSave, 2) 'calculate the NPV of all the energy saved, again taking the inflation rate into account Dim enEffMthlyEnCostSav, npvEnEffEnCostSav, npvTotSav As Double Dim enEffLifetime As Long 'Dim pvLifetime As Long enEffLifetime = Val(txtRenLifetime.Text) enEffMthlyEnCostSav = enCostPrePMth - enCostPostPMth If modDiscRateMtly = 0 Then npvEnEffEnCostSav = enEffMthlyEnCostSav * 12 * enEffLifetime Else npvEnEffEnCostSav = enEffMthlyEnCostSav * (1 - (1 / (1 + modDiscRateMtly)) ^ (12 * enEffLifetime)) / (modDiscRateMtly) End If npvTotSav = npvEnEffEnCostSav + npvPVEarnings txtNPVEnCostSav.Text = Math.Round(npvTotSav, 0) 'calculate the monthly CO2 tax savings, including from PV if any. Note that the PV production might need to be split??? 'Pre-retrofit emissions Dim preCO2Fact, preRetCO2Fact2, preCO2TaxElec, preRetCO2Py, preRetFact2CO2py As Double 'note: Fact emissions are the actual emissions, Fact2 emissions determine the CO2 tax If comboPreRet.Text = "Gas" Then preCO2Fact = 0.20088 preRetCO2Fact2 = 0.20088 Else If comboPreRet.Text = "Oil" Then preCO2Fact = 0.245 preRetCO2Fact2 = 0.245 Else If comboPreRet.Text = "Coal" Then preCO2Fact = 0.84 preRetCO2Fact2 = 0.84 Else If comboPreRet.Text = "Pellets" Then preCO2Fact = 0.2 preRetCO2Fact2 = 0.022 Else If comboPreRet.Text = "Electricity" Then preCO2Fact = 0.4 preCO2TaxElec = 0 preRetCO2Fact2 = 0 End If End If End If End If End If 'for actual pre-retrofit CO2 emissions preRetCO2Py = preRetCons * floorArea * preCO2Fact / 1000 txtPreRetCO2.Text = Math.Round(preRetCO2Py, 2) 'for taxed pre-retrofit CO2 emissions preRetFact2CO2py = preRetCons * floorArea * preRetCO2Fact2 / 1000 '## hold this for tax calculation 'post-retrofit emissions Dim postCO2Fact, postCO2Fact2, postCO2TaxElec, postRetCO2Py, postRetFact2CO2py As Double If comboPostRet.Text = "Gas" Then postCO2Fact = 0.20088 Else If comboPostRet.Text = "Oil" Then postCO2Fact = 0.245 postCO2Fact2 = 0.245 Else If comboPostRet.Text = "Coal" Then postCO2Fact = 0.84 postCO2Fact2 = 0.84 Else If comboPostRet.Text = "Pellets" Then postCO2Fact = 0.2 postCO2Fact2 = 0.022 Else If comboPostRet.Text = "Electricity" Then postCO2Fact = 0.4 postCO2TaxElec = 0 postCO2Fact2 = 0 End If End If End If End If End If postRetCO2Py = postRetCons * floorArea * postCO2Fact / 1000 txtPostRetCO2.Text = Math.Round(postRetCO2Py, 2) 'for taxed post-retrofit CO2 emissions postRetFact2CO2py = preRetCons * floorArea * postCO2Fact2 / 1000 '## hold this for tax calculation 'calculate emissions saved through energy efficiency increase Dim enEffCO2saved As Double enEffCO2saved = (preRetCO2Py - postRetCO2Py) * enEffLifetime 'calculate emissions saved through PV Dim pvCO2saved, pvCO2SavPy As Double pvCO2saved = pvLifetime * pvProdn * 0.35 / 1000 pvCO2SavPy = pvProdn * 0.35 / 1000 txtPVCO2SavPy.Text = Math.Round(pvCO2SavPy, 2) 'calculate all CO2 emissions saved Dim allCO2Saved As Double allCO2Saved = enEffCO2saved + pvCO2saved txt25YCO2sav.Text = Math.Round(allCO2Saved, 1) 'calculate NPV of CO2 savings ## new change 16 Feb 2024 Dim costOfCO2Saved, npvCostOfCO2Saved As Double npvCostOfCO2Saved = Math.Round(npvTotCosts / allCO2Saved, 0) costOfCO2Saved = enEffCost / allCO2Saved txtEuroPTCO2.Text = Math.Round(costOfCO2Saved, 0) 'Calculate the CO2 tax saved saved over the lifetime of the renovations (not for PV as this is electricity) Dim enEffCO2SavPy, npvCO2TaxSav, CO2TaxInfln, modCO2TaxDiscRate, enEffCO2TaxSavpy, CO2TaxRate As Double enEffCO2SavPy = enEffCO2saved / enEffLifetime CO2TaxRate = Val(txtCO2TaxRate.Text) CO2TaxInfln = Val(txtCO2pcInc.Text) enEffCO2TaxSavpy = enEffCO2SavPy * CO2TaxRate 'get inflation adjusted discount rate for this modCO2TaxDiscRate = (1 + discRate / 100) / (1 + CO2TaxInfln / 100) '## added 16 Feb 2024 If modCO2TaxDiscRate = 1 Then npvCO2TaxSav = enEffCO2TaxSavpy * enEffLifetime Else 'now use discount rate formula on an annual basis npvCO2TaxSav = enEffCO2TaxSavpy * (1 - (1 / (modCO2TaxDiscRate ^ enEffLifetime))) / (modCO2TaxDiscRate - 1) End If txtNPVTaxSav.Text = Math.Round(npvCO2TaxSav, 0) 'calculate the total benefits and profit or loss Dim npvTotBenefits, npvProfitLoss As Double npvTotBenefits = npvEnEffEnCostSav + npvCO2TaxSav + npvPVEarnings txtTotSav2.Text = Math.Round(npvTotBenefits, 0) npvProfitLoss = npvTotBenefits - npvTotCosts txtNetLossGain.Text = Math.Round(npvProfitLoss, 0) If npvProfitLoss < 0 Then Label35.Text = "You suffer a net loss:" Else If npvProfitLoss > 0 Then Label35.Text = "You make a net gain:" Else Label35.Text = "You break even:" End If End If 'calculate the cost-neutral rent increase Dim costNeutRentInc As Double costNeutRentInc = mthlyEnCostSave / floorArea txtCostNeutRentInc.Text = Math.Round(costNeutRentInc, 2) ' calculate the percentage of NPV costs that would be recovered through cost-neutral rent increase Dim pcCovered, npvRentInc, mthlyPCRentInc, totRentInc, discountedMthlyRentInc, testNPV As Double mthlyPCRentInc = 1.15 ^ (1 / 36) - 1 discountedMthlyRentInc = (mthlyPCRentInc + 1) / (1 + discRateMthly) npvRentInc = costNeutRentInc * floorArea * (1 - (1 / (discountedMthlyRentInc) ^ (enEffLifetime * 12))) / (discountedMthlyRentInc - 1) pcCovered = npvRentInc / npvTotCosts * 100 txtPCRecov.Text = Math.Round(pcCovered, 2) 'calculate percentage payback for owner-occupier Dim pcPayback As Double pcPayback = (npvTotBenefits) / npvTotCosts * 100 txtPCPayback.Text = Math.Round(pcPayback, 2) 'do the charts Dim profLoss, npvTotCostsRev As Long Chart1.Series("CBA").Points.Clear() npvTotCostsRev = (-1) * npvTotCosts Chart1.Series("CBA").Points.AddXY("Costs", npvTotCostsRev) Chart1.Series("CBA").Points.AddXY("Benefits", npvTotBenefits) 'Set the first two bar colors Chart1.Series("CBA").Points(0).Color = Color.HotPink Chart1.Series("CBA").Points(1).Color = Color.Black ' set the last color bar according to whether it's profit or loss 'profLoss = npvTotBenefits - npvTotCosts 'txtNetLossGain.Text = CStr(npvProfitLoss) If npvProfitLoss > 0 Then Label35.Text = "You make a net gain:" Chart1.Series("CBA").Points.AddXY("Profit", npvProfitLoss) Chart1.Series("CBA").Points(2).Color = Color.Green Else If npvProfitLoss < 0 Then Label35.Text = "You suffer a net loss:" Chart1.Series("CBA").Points.AddXY("Loss", npvProfitLoss) Chart1.Series("CBA").Points(2).Color = Color.Red Else Label35.Text = "You break even, no loss or gain" End If End If End Sub Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click MsgBox("This is the total cost of the retrofit including both 'anyway' costs and energy efficiency improvement costs - which include transaction costs. Also include PV costs, if any.") End Sub Private Sub Label3_Click(sender As Object, e As EventArgs) MsgBox("The Anyway Costs are the costs for renovations that are needed due to the age or condition of the building. This calculator does not count them as part of the energy efficiency improvement costs.") End Sub Private Sub txtTotalCost_TextChanged(sender As Object, e As EventArgs) Handles txtTotalCost.TextChanged If IsNumeric(txtTotCosts2.Text) = True Then whamo2() 'Else ' MsgBox("Please put only numerical values in the text boxes, and use dots, not commas, for decimal points.") End If End Sub Private Sub txtAnyway_TextChanged(sender As Object, e As EventArgs) Handles txtAnyway.TextChanged If IsNumeric(txtTotCosts2.Text) = True Then whamo2() End If End Sub Private Sub txtOwnCap_TextChanged(sender As Object, e As EventArgs) Handles txtOwnCap.TextChanged If IsNumeric(txtTotCosts2.Text) = True Then whamo2() End If End Sub Private Sub txtSubsidies_TextChanged(sender As Object, e As EventArgs) Handles txtSubsidies.TextChanged If IsNumeric(txtTotCosts2.Text) = True Then whamo2() End If End Sub Private Sub txtEnEffCost_TextChanged(sender As Object, e As EventArgs) Handles txtEnEffCost.TextChanged End Sub Private Sub Label8_Click(sender As Object, e As EventArgs) Handles Label8.Click MsgBox("The default annual interest rate here, of 4%, is probably on the low side, so it pays to check with local banks, etc.") End Sub Private Sub txtBorrowed_TextChanged(sender As Object, e As EventArgs) Handles txtBorrowed.TextChanged End Sub Private Sub txtIntRate_TextChanged(sender As Object, e As EventArgs) Handles txtIntRate.TextChanged If IsNumeric(txtTotCosts2.Text) = True Then whamo2() End If End Sub Private Sub txtLoanTerm_TextChanged(sender As Object, e As EventArgs) Handles txtLoanTerm.TextChanged If IsNumeric(txtTotCosts2.Text) = True Then whamo2() End If End Sub Private Sub txtOppInt_TextChanged(sender As Object, e As EventArgs) Handles txtOppInt.TextChanged If IsNumeric(txtTotCosts2.Text) = True Then whamo2() End If End Sub Private Sub txtDiscRate_TextChanged(sender As Object, e As EventArgs) Handles txtDiscRate.TextChanged If IsNumeric(txtTotCosts2.Text) = True Then If IsNumeric(txtDiscRate.Text) = True Then If Val(txtDiscRate.Text) > 0 Then whamo2() Else MsgBox("Please put a number greater than zero in this box, and no negative numbers") End If End If End If End Sub Private Sub txtTotalRepay_TextChanged(sender As Object, e As EventArgs) Handles txtTotalRepay.TextChanged End Sub Private Sub txtNPVLoan_TextChanged(sender As Object, e As EventArgs) Handles txtNPVLoan.TextChanged End Sub Private Sub Label17_Click(sender As Object, e As EventArgs) Handles Label17.Click MsgBox("This is the actual consumption (Verbrauch) not the theoretical consumption (Bedarf). It is very important to estimate the actual post-retrofit consumption, taking likely rebound effects into account.") End Sub Private Sub txtPreRetCons_TextChanged(sender As Object, e As EventArgs) Handles txtPreRetCons.TextChanged If IsNumeric(txtTotCosts2.Text) = True Then whamo2() End If End Sub Private Sub txtPostRetCons_TextChanged(sender As Object, e As EventArgs) End Sub Private Sub txtFloorArea_TextChanged(sender As Object, e As EventArgs) Handles txtFloorArea.TextChanged If IsNumeric(txtTotCosts2.Text) = True Then whamo2() End If End Sub Private Sub txtEnCost_TextChanged(sender As Object, e As EventArgs) Handles txtEnCost.TextChanged If IsNumeric(txtTotCosts2.Text) = True Then whamo2() End If End Sub Private Sub comboPreRet_SelectedIndexChanged(sender As Object, e As EventArgs) Handles comboPreRet.SelectedIndexChanged If IsNumeric(txtTotCosts2.Text) = True Then whamo2() End If End Sub Private Sub comboPostRet_SelectedIndexChanged(sender As Object, e As EventArgs) Handles comboPostRet.SelectedIndexChanged If IsNumeric(txtTotCosts2.Text) = True Then whamo2() End If End Sub Private Sub txtCO2TaxRate_TextChanged(sender As Object, e As EventArgs) Handles txtCO2TaxRate.TextChanged If IsNumeric(txtTotCosts2.Text) = True Then whamo2() End If End Sub Private Sub txtPostRetCons_TextChanged_1(sender As Object, e As EventArgs) Handles txtPostRetCons.TextChanged If IsNumeric(txtTotCosts2.Text) = True Then whamo2() End If End Sub Private Sub Chart1_Click(sender As Object, e As EventArgs) End Sub Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click MsgBox("The Anyway Costs are the costs for renovations that are needed due to the age or condition of the building. This calculator does not count them as part of the energy efficiency improvement costs. If you want to include them in the costing, you can just write 0 for this box.") End Sub Private Sub Label10_Click(sender As Object, e As EventArgs) Handles Label10.Click MsgBox("Your discount rate is calculated on the basis of the percentage reduction in value to you, today, of money you will receive or spend one year from now. It uses the economists' formula of 1 / (1 + interest rate/100). Note, that all interest and discount rate calculations in the tool are done on a monthly basis, using a formula to transfer annual interest or discount rates to monthly equivalents.") End Sub Private Sub Label11_Click(sender As Object, e As EventArgs) Handles Label11.Click MsgBox("This is the annual percentage return on an alternative investment you may wish to make with the money from your savings that you invest in the energy efficiency retrofit.") End Sub Private Sub Label16_Click(sender As Object, e As EventArgs) Handles Label16.Click MsgBox("This is the actual consumption (Verbrauch) not the theoretical consumption (Bedarf). It is very important to enter the actual consumption, preferably the average of the past three years.") End Sub Private Sub Label37_Click(sender As Object, e As EventArgs) End Sub Private Sub btnInfo_Click(sender As Object, e As EventArgs) Handles btnInfo.Click MsgBox("The program initially gives a set of default values for costs, energy connsumption, etc. Put your own values in the white boxes. If you're not sure what some of the labels mean, click on them and a message box will appear. As you change the data in each box, the program will re-calculate the results for the grey text boxes and the graph. In case you're not sure if this has worked, click on 'Re-calculate' button at the top right. The default settings are from an update of a study of retrofittig a 4-apartment building, taking prebound and rebound effects into account. When you finish inputting your data, you can save all the inputs and results to a spreadsheet by clicking on the button at the bottom right and following the prompts.") End Sub Private Sub Label29_Click(sender As Object, e As EventArgs) Handles Label29.Click End Sub Private Sub txtLoanMthlyRepay_TextChanged(sender As Object, e As EventArgs) Handles txtLoanMthlyRepay.TextChanged End Sub Private Sub txtOppCosts_TextChanged(sender As Object, e As EventArgs) Handles txtOppCosts.TextChanged End Sub Private Sub txtEnSaved_TextChanged(sender As Object, e As EventArgs) Handles txtEnSaved.TextChanged End Sub Private Sub txtPreRetCO2_TextChanged(sender As Object, e As EventArgs) Handles txtPreRetCO2.TextChanged End Sub Private Sub Label4_Click(sender As Object, e As EventArgs) Handles Label4.Click End Sub Private Sub Label5_Click(sender As Object, e As EventArgs) Handles Label5.Click MsgBox("This is money that you could have invested elsewhere, possibly for a good return, so it incurs 'opportunity' costs, which are covered below.") End Sub Private Sub Label6_Click(sender As Object, e As EventArgs) Handles Label6.Click MsgBox("This is only subsidies that are given as cash value. If there is a special loan with subsidised interest rate, this is covered in the box for subsidised loan.") End Sub Private Sub Label9_Click(sender As Object, e As EventArgs) Handles Label9.Click MsgBox("Generally, the longer the term, the lower the monthly payments but the higher the sum total of interest repayments.") End Sub Private Sub Label15_Click(sender As Object, e As EventArgs) Handles Label15.Click MsgBox("Your opportunity costs are the net present value of the sum of the returns you would have made over your chosen investment time horizon (above text box), if you had invested your up-front capital in some other venture.") End Sub Private Sub Label14_Click(sender As Object, e As EventArgs) Handles Label14.Click MsgBox("The 'net present value' of money that you will pay out monthly over the next years is less than the actual amount you will pay, because of your discount rate. The value of money to you today that you will pay or receive in one year's time is diminished by the percentage of your discount rate.") End Sub Private Sub Label26_Click(sender As Object, e As EventArgs) Handles Label26.Click End Sub Private Sub Label22_Click(sender As Object, e As EventArgs) Handles Label22.Click MsgBox("The CO2 tax for home heating is currently kept low, but could increase to well over 100 euros per tonne of CO2 in the next few years. You'll need to check what it is at the moment.") End Sub Private Sub Label19_Click(sender As Object, e As EventArgs) Handles Label19.Click MsgBox("This is the floor area inside the front door of the apartments or house, excluding external stairways and lobbies, basement areas and unused lofts which will not be heated.") End Sub Private Sub Label20_Click(sender As Object, e As EventArgs) Handles Label20.Click MsgBox("Enter the cost of energy for the energy source (Gas, Electricity, etc.) that the dwelling uses prior to the retrofit and would continue to use if it is not retrofitted . You'll need to make a best-guess of what you think the average cost is likely to be over the next 25 years.") End Sub Private Sub Label27_Click(sender As Object, e As EventArgs) Handles Label27.Click MsgBox("The figure here is very important for society at large. You can reduce CO2 emissions for a cost of about 100 euros per tonne by investing in a wind turbine, while an economically efficient, problem-free retrofit of an old house to a modest standard of about 70-100 kWh per square meter per year usually costs 200-300 euros per tonne of CO2 reduction. If your figure here is much higher than this, you may wish to reconsider whether the planned retrofit is too ambitious or whether the cost quotes make sense.") End Sub Private Sub txtEnCostSav_TextChanged(sender As Object, e As EventArgs) Handles txtEnCostSav.TextChanged End Sub Private Sub txtEnCostPost_TextChanged(sender As Object, e As EventArgs) Handles txtEnCostPost.TextChanged whamo2() End Sub Private Sub txtCO2TaxSav_TextChanged(sender As Object, e As EventArgs) whamo2() End Sub Private Sub Label38_Click(sender As Object, e As EventArgs) Handles Label38.Click MsgBox("Enter the cost per kWh of the energy source the dwelling will use (gas, electricity, etc) after being retrofitted. Energy prices are currently unstable so you will need to make a best guess of the likely average price over the next 25 years.") End Sub Private Sub Label3_Click_1(sender As Object, e As EventArgs) MsgBox("This gives the number of months until the net present value of benefits (energy cost and CO2 tax savings) are greater than the net present value of the money you will have so far spent.") End Sub Private Sub Label39_Click(sender As Object, e As EventArgs) MsgBox("The 'simple break even point' is the number of months until the accumulated sum of your benefits (energy and tax savings) first exceeds the money paid up-front for the retrofit, minus anyway costs and subsidies. It is not a reliable measure because it does not take into account the interest you will be paying on a loan, your discount rate or your opportunity costs.") End Sub Private Sub Button1_Click_2(sender As Object, e As EventArgs) End Sub Private Sub Label41_Click(sender As Object, e As EventArgs) Handles Label41.Click MsgBox("Enter the annual gain from PV. This will need to be estimated either using other software, or by asking a specialist, in relation to the building and its occupants' consumption patterns. It is the savings from self-consumption plus the income from grid feed-in. It depends on the system size and household elecricty load profile in relation to the solar electricity production profile.") End Sub Private Sub txtPVannaulIncome_TextChanged(sender As Object, e As EventArgs) Handles txtPVannaulIncome.TextChanged If IsNumeric(txtPVannaulIncome.Text) = True Then whamo2() End If End Sub Private Sub Label40_Click(sender As Object, e As EventArgs) MsgBox("This is the total cost of the PV system including installation, grid connection fees, etc.") End Sub Private Sub Form1_Load_1(sender As Object, e As EventArgs) Handles MyBase.Load whamo2() End Sub Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click whamo2() End Sub Private Sub txtAltInvHzn_TextChanged(sender As Object, e As EventArgs) Handles txtAltInvHzn.TextChanged If IsNumeric(txtAltInvHzn.Text) = True Then whamo2() Else MsgBox("Please put a numeric value in this box, i.e. the number of years you think your up-front cash could have been invested in a more profitable project") End If End Sub Private Sub Label7_Click(sender As Object, e As EventArgs) Handles Label7.Click End Sub Private Sub Label51_Click(sender As Object, e As EventArgs) Handles Label51.Click MsgBox("This is calculated by the software as the total loan needed less any subsidised loan.") End Sub Private Sub txtSubLoan_TextChanged(sender As Object, e As EventArgs) Handles txtSubLoan.TextChanged whamo2() End Sub Private Sub Label50_Click(sender As Object, e As EventArgs) Handles Label50.Click MsgBox("Again, check the information of the subsidy agency, such as the KfW, for the likely loan term.") End Sub Private Sub Label45_Click(sender As Object, e As EventArgs) Handles Label45.Click End Sub Private Sub Label62_Click(sender As Object, e As EventArgs) Handles lblExpl1.Click MsgBox("In this box, put the amount of energy the heating system will use, regardless of whether it comes from gas, the electricity grid, or your own PV system. If there is a PV system, the energy it produces will be automatically subtracted from other totals to calculate CO2 emissions, etc.") End Sub Private Sub lblExpl2_Click(sender As Object, e As EventArgs) Handles lblExpl2.Click MsgBox("If there is rooftoop PV, this is the total monthly energy savings for the period when both the energy-efficiency measures and the PV system are still functioning. The NPV of the energy cost savings given below also counts both energy-efficiency savings and PV (if any) savings.") End Sub Private Sub txtNPVEnCostSav_TextChanged(sender As Object, e As EventArgs) Handles txtNPVEnCostSav.TextChanged End Sub Private Sub Label62_Click_1(sender As Object, e As EventArgs) Handles Label62.Click MsgBox("This is a very difficult percentage to estimate, but bear in mind that (a) there is continual political pressure to keep household energy prices low, but (b) some organisations have a vested interest in saying that energy prices will rise continually and long-term at a very high rate.") End Sub Private Sub Label64_Click(sender As Object, e As EventArgs) Handles Label64.Click MsgBox("The calculation of NPV of PV income uses the same inflation rate as for energy price, given in the third column. Also, note that the PV production does not reduce the CO2 taxes, as these are not applied to electricity.") End Sub Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs) Handles Panel1.Paint End Sub Private Sub txtPVCO2SavPy_TextChanged(sender As Object, e As EventArgs) Handles txtPVCO2SavPy.TextChanged End Sub Private Sub Label32_Click(sender As Object, e As EventArgs) Handles Label32.Click End Sub Private Sub Label35_Click(sender As Object, e As EventArgs) Handles Label35.Click End Sub Private Sub Label67_Click(sender As Object, e As EventArgs) Handles Label67.Click End Sub Private Sub Label58_Click(sender As Object, e As EventArgs) Handles Label58.Click MsgBox("In Germany this is usually between 850 and 1000 times the number of kWp, depending on how sunny your region is.") End Sub Private Sub btnExport_Click(sender As Object, e As EventArgs) Handles btnExport.Click Dim runNum As Integer runNum = Val(txtRunNum.Text) If runNum = 0 Then Saver1() Else '## first check if the file is open 'Saver2() FileInUse() End If End Sub Public Function FileInUse() As Boolean '##new function added 31Dec2023 Dim InUse As Boolean = False Dim The_File As String The_File = txtPath.Text & ".xlsx" 'MsgBox("The path is " & The_File) If IO.File.Exists(The_File) Then Try Using FS As New IO.FileStream(The_File, IO.FileMode.Open) ', IO.FileAccess.ReadWrite, IO.FileShare.None) InUse = False FS.Close() '##New attempt ### yes, it made it work Saver2() ' MsgBox("Saver2 has been called") End Using Catch InUse = True MsgBox("The file is open. Please close it and try again.") End Try End If Return InUse End Function Public Sub Saver1() Dim myDialog As SaveFileDialog myDialog = SaveFileDialog1 SaveFileDialog1.ShowDialog() Dim myPath As String myPath = myDialog.FileName '##check that there is a file path ## coded 19Dec2023 If myPath = "" Then MsgBox("As there is no file named, you will have to start the save process again") GoTo whoops End If 'MsgBox("Your file name is " & myPath) 'On Error GoTo BadEnd Dim runNum As Integer runNum = Val(txtRunNum.Text) Dim oExcel As Object Dim oBook As Object Dim oSheet As Object 'get the name of the scenario Dim scenario As String scenario = txtScenario.Text 'Start a new workbook in Excel oExcel = CreateObject("Excel.Application") oBook = oExcel.Workbooks.Add 'Add data to cells of the first worksheet in the new workbook oSheet = oBook.Worksheets(1) oSheet.Range("A1").Value = "Case" oSheet.Range("B1").Value = "Total costs" oSheet.Range("C1").Value = "Anyway costs" oSheet.Range("D1").Value = "Energy-efficiency costs" oSheet.Range("E1").Value = "Own capital investment" oSheet.Range("F1").Value = "Cash subsidy" oSheet.Range("G1").Value = "Discount rate (%)" oSheet.Range("H1").Value = "Technical lifetime (y)" oSheet.Range("I1").Value = "PV annual income" oSheet.Range("J1").Value = "PV annual production (kWh)" oSheet.Range("K1").Value = "PV system lifetime (y)" oSheet.Range("L1").Value = "NPV of PV income" oSheet.Range("M1").Value = "Alternative investment return (%/y)" oSheet.Range("N1").Value = "Altv invstmt time horizon (y)" oSheet.Range("O1").Value = "NPV of opportunity costs" oSheet.Range("P1").Value = "Subsdised loan amount" oSheet.Range("Q1").Value = "Subsidised loan interest rate (%/y)" oSheet.Range("R1").Value = "Subsidised loan term (y)" oSheet.Range("S1").Value = "Subsd loan monthly repayments" oSheet.Range("T1").Value = "Subsd loan total repayments" oSheet.Range("U1").Value = "Subsd loan NPV of repayments" oSheet.Range("V1").Value = "Ordinary loan amount" oSheet.Range("W1").Value = "Loan interest rate (%/y)" oSheet.Range("X1").Value = "Loan term (y)" oSheet.Range("Y1").Value = "Loan monthly repayments" oSheet.Range("Z1").Value = "Loan total repayments" oSheet.Range("AA1").Value = "NPV of loan repayments" oSheet.Range("AB1").Value = "CO2 tax rate (euro/tCO2)" oSheet.Range("AC1").Value = "Annual increase in CO2 tax rate (%)" oSheet.Range("AD1").Value = "NPV of CO2 tax savings" oSheet.Range("AE1").Value = "Pre-retrofit consumption (kWh/m2/y)" oSheet.Range("AF1").Value = "Post-retrofit consumption (kWh/m2/y)" oSheet.Range("AG1").Value = "Hence energy saved (kWh/m2/y)" oSheet.Range("AH1").Value = "Floor area (m2)" oSheet.Range("AI1").Value = "Pre-retrofit energy source" oSheet.Range("AJ1").Value = "Pre-retrofit energy price (euro/kWh)" oSheet.Range("AK1").Value = "Post-retrofit energy source" oSheet.Range("AL1").Value = "Post-retrofit energy price (euro/kWh)" oSheet.Range("AM1").Value = "Energy price inflation rate (%/y)" oSheet.Range("AN1").Value = "Monthly energy savings (euro/month)" oSheet.Range("AO1").Value = "NPV of energy cost savings" oSheet.Range("AP1").Value = "Pre-retrofit emissions (tCO2/y)" oSheet.Range("AQ1").Value = "Post-retrofit emissions (tCO2/y)" oSheet.Range("AR1").Value = "CO2 savings from PV (tCO2/y)" oSheet.Range("AS1").Value = "CO2 savings in system lifetime (tCO2)" oSheet.Range("AT1").Value = "NPV of cost of CO2 saved (euro/tCO2)" oSheet.Range("AU1").Value = "NPV of total costs" oSheet.Range("AV1").Value = "NPV of total benefits" oSheet.Range("AW1").Value = "NPV of profit or loss" oSheet.Range("AX1").Value = "Percentage return over lifetime of measures (%)" oSheet.Range("AY1").Value = "Cost-neutral rent increase (euro/m2/month)" oSheet.Range("AZ1").Value = "% of costs covered through cost-neutral rent increase" oSheet.Range("A2").Value = scenario oSheet.Range("B2").Value = Val(txtTotalCost.Text) oSheet.Range("C2").Value = Val(txtAnyway.Text) oSheet.Range("D2").Value = Val(txtEnEffCost.Text) oSheet.Range("E2").Value = Val(txtOwnCap.Text) oSheet.Range("F2").Value = Val(txtSubsidies.Text) oSheet.Range("G2").Value = Val(txtDiscRate.Text) oSheet.Range("H2").Value = Val(txtRenLifetime.Text) oSheet.Range("I2").Value = Val(txtPVannaulIncome.Text) oSheet.Range("J2").Value = Val(txtPVProdn.Text) oSheet.Range("K2").Value = Val(txtPVLifetime.Text) oSheet.Range("L2").Value = Val(txtNPVPVEarnings.Text) oSheet.Range("M2").Value = Val(txtOppInt.Text) oSheet.Range("N2").Value = Val(txtAltInvHzn.Text) oSheet.Range("O2").Value = Val(txtOppCosts.Text) oSheet.Range("P2").Value = Val(txtSubLoan.Text) oSheet.Range("Q2").Value = Val(txtSubIntRate.Text) oSheet.Range("R2").Value = Val(txtSubLoanYrs.Text) oSheet.Range("S2").Value = Val(txtSubLoanMthlyRepay.Text) oSheet.Range("T2").Value = Val(txtSubLoanTotRepay.Text) oSheet.Range("U2").Value = Val(txtNPVSubLoanRepayments.Text) oSheet.Range("V2").Value = Val(txtNonSubLoan.Text) oSheet.Range("W2").Value = Val(txtIntRate.Text) oSheet.Range("X2").Value = Val(txtLoanTerm.Text) oSheet.Range("Y2").Value = Val(txtLoanMthlyRepay.Text) oSheet.Range("Z2").Value = Val(txtTotalRepay.Text) oSheet.Range("AA2").Value = Val(txtNPVLoan.Text) oSheet.Range("AB2").Value = Val(txtCO2TaxRate.Text) oSheet.Range("AC2").Value = Val(txtCO2pcInc.Text) oSheet.Range("AD2").Value = Val(txtNPVTaxSav.Text) oSheet.Range("AE2").Value = Val(txtPreRetCons.Text) oSheet.Range("AF2").Value = Val(txtPostRetCons.Text) oSheet.Range("AG2").Value = Val(txtEnSaved.Text) oSheet.Range("AH2").Value = Val(txtFloorArea.Text) oSheet.Range("AI2").Value = comboPreRet.Text oSheet.Range("AJ2").Value = Val(txtEnCost.Text) oSheet.Range("AK2").Value = comboPostRet.Text oSheet.Range("AL2").Value = Val(txtEnCostPost.Text) oSheet.Range("AM2").Value = Val(txtEnPriceInfln.Text) oSheet.Range("AN2").Value = Val(txtEnCostSav.Text) oSheet.Range("AO2").Value = Val(txtNPVEnCostSav.Text) oSheet.Range("AP2").Value = Val(txtPreRetCO2.Text) oSheet.Range("AQ2").Value = Val(txtPostRetCO2.Text) oSheet.Range("AR2").Value = Val(txtPVCO2SavPy.Text) oSheet.Range("AS2").Value = Val(txt25YCO2sav.Text) oSheet.Range("AT2").Value = Val(txtEuroPTCO2.Text) oSheet.Range("AU2").Value = Val(txtNPVTotCost.Text) oSheet.Range("AV2").Value = Val(txtTotSav2.Text) oSheet.Range("AW2").Value = Val(txtNetLossGain.Text) oSheet.Range("AX2").Value = Val(txtPCPayback.Text) oSheet.Range("AY2").Value = Val(txtCostNeutRentInc.Text) oSheet.Range("AZ2").Value = Val(txtPCRecov.Text) txtRunNum.Text = Val(1 + runNum) 'Save the Workbook and Quit Excel oBook.SaveAs(myPath) txtPath.Text = myPath '## new 19Dec2023 MsgBox("Your data has been saved as an excel file. If you do another case in this session, its data will be appended to the same worksheet in the excel file. IF YOU OPEN THE FILE TO LOOK AT IT YOU MUST CLOSE IT AGAIN BEFORE ADDING ANOTHER SCENARIO'S DATA") oExcel.Quit whoops: End Sub Private Sub Label30_Click(sender As Object, e As EventArgs) Handles Label30.Click MsgBox("This figure may look surprisingly high, but note that the calculation assumes there is also a general rent increase of 15% every three years (but calculated as if it is a monthly rent increase of the 36th root of the 15% increase, since it is not known which part of the 3-year rent increase cycle you are on). Also, the tool discountss rent increases in the future by the same discount rate that discounts future costs, such as mortgage prepayments. ") End Sub Private Sub txtRenLifetime_TextChanged(sender As Object, e As EventArgs) Handles txtRenLifetime.TextChanged If IsNumeric(txtRenLifetime.Text) = True Then whamo2() End If End Sub Private Sub txtPVProdn_TextChanged(sender As Object, e As EventArgs) Handles txtPVProdn.TextChanged If IsNumeric(txtPVProdn.Text) = True Then whamo2() End If End Sub Private Sub txtPVLifetime_TextChanged(sender As Object, e As EventArgs) Handles txtPVLifetime.TextChanged If IsNumeric(txtPVLifetime.Text) = True Then whamo2() End If End Sub Private Sub txtSubIntRate_TextChanged(sender As Object, e As EventArgs) Handles txtSubIntRate.TextChanged If IsNumeric(txtSubIntRate.Text) = True Then whamo2() End If End Sub Private Sub txtSubLoanYrs_TextChanged(sender As Object, e As EventArgs) Handles txtSubLoanYrs.TextChanged If IsNumeric(txtSubLoanYrs.Text) = True Then whamo2() End If End Sub Private Sub txtCO2pcInc_TextChanged(sender As Object, e As EventArgs) Handles txtCO2pcInc.TextChanged If IsNumeric(txtCO2pcInc.Text) = True Then whamo2() End If End Sub Private Sub txtEnPriceInfln_TextChanged(sender As Object, e As EventArgs) Handles txtEnPriceInfln.TextChanged If IsNumeric(txtEnPriceInfln.Text) = True Then whamo2() End If End Sub Private Sub txtNonSubLoan_TextChanged(sender As Object, e As EventArgs) Handles txtNonSubLoan.TextChanged End Sub Private Sub txtFilePath_TextChanged(sender As Object, e As EventArgs) End Sub Private Sub SaveFileDialog1_FileOk(sender As Object, e As CancelEventArgs) Handles SaveFileDialog1.FileOk Dim FileToSaveAs As String = SaveFileDialog1.FileName End Sub Public Sub Saver2() Dim runNum As Integer runNum = Val(txtRunNum.Text) Dim myDialog As SaveFileDialog myDialog = SaveFileDialog1 Dim myPath As String 'myPath = myDialog.FileName myPath = txtPath.Text 'MsgBox("Your file name is " & myPath) Dim oExcel As Object Dim oBook As Object Dim oSheet As Object oExcel = CreateObject("Excel.Application") oBook = oExcel.Workbooks.open(myPath) '### key thing!! oSheet = oBook.worksheets(1) 'get the name of the scenario Dim scenario As String scenario = txtScenario.Text oSheet.Range("A" & runNum + 2).Value = scenario oSheet.Range("B" & runNum + 2).Value = Val(txtTotalCost.Text) oSheet.Range("C" & runNum + 2).Value = Val(txtAnyway.Text) oSheet.Range("D" & runNum + 2).Value = Val(txtEnEffCost.Text) oSheet.Range("E" & runNum + 2).Value = Val(txtOwnCap.Text) oSheet.Range("F" & runNum + 2).Value = Val(txtSubsidies.Text) oSheet.Range("G" & runNum + 2).Value = Val(txtDiscRate.Text) oSheet.Range("H" & runNum + 2).Value = Val(txtRenLifetime.Text) oSheet.Range("I" & runNum + 2).Value = Val(txtPVannaulIncome.Text) oSheet.Range("J" & runNum + 2).Value = Val(txtPVProdn.Text) oSheet.Range("K" & runNum + 2).Value = Val(txtPVLifetime.Text) oSheet.Range("L" & runNum + 2).Value = Val(txtNPVPVEarnings.Text) oSheet.Range("M" & runNum + 2).Value = Val(txtOppInt.Text) oSheet.Range("N" & runNum + 2).Value = Val(txtAltInvHzn.Text) oSheet.Range("O" & runNum + 2).Value = Val(txtOppCosts.Text) oSheet.Range("P" & runNum + 2).Value = Val(txtSubLoan.Text) oSheet.Range("Q" & runNum + 2).Value = Val(txtSubIntRate.Text) oSheet.Range("R" & runNum + 2).Value = Val(txtSubLoanYrs.Text) oSheet.Range("S" & runNum + 2).Value = Val(txtSubLoanMthlyRepay.Text) oSheet.Range("T" & runNum + 2).Value = Val(txtSubLoanTotRepay.Text) oSheet.Range("U" & runNum + 2).Value = Val(txtNPVSubLoanRepayments.Text) oSheet.Range("V" & runNum + 2).Value = Val(txtNonSubLoan.Text) oSheet.Range("W" & runNum + 2).Value = Val(txtIntRate.Text) oSheet.Range("X" & runNum + 2).Value = Val(txtLoanTerm.Text) oSheet.Range("Y" & runNum + 2).Value = Val(txtLoanMthlyRepay.Text) oSheet.Range("Z" & runNum + 2).Value = Val(txtTotalRepay.Text) oSheet.Range("AA" & runNum + 2).Value = Val(txtNPVLoan.Text) oSheet.Range("AB" & runNum + 2).Value = Val(txtCO2TaxRate.Text) oSheet.Range("AC" & runNum + 2).Value = Val(txtCO2pcInc.Text) oSheet.Range("AD" & runNum + 2).Value = Val(txtNPVTaxSav.Text) oSheet.Range("AE" & runNum + 2).Value = Val(txtPreRetCons.Text) oSheet.Range("AF" & runNum + 2).Value = Val(txtPostRetCons.Text) oSheet.Range("AG" & runNum + 2).Value = Val(txtEnSaved.Text) oSheet.Range("AH" & runNum + 2).Value = Val(txtFloorArea.Text) oSheet.Range("AI" & runNum + 2).Value = comboPreRet.Text oSheet.Range("AJ" & runNum + 2).Value = Val(txtEnCost.Text) oSheet.Range("AK" & runNum + 2).Value = comboPostRet.Text oSheet.Range("AL" & runNum + 2).Value = Val(txtEnCostPost.Text) oSheet.Range("AM" & runNum + 2).Value = Val(txtEnPriceInfln.Text) oSheet.Range("AN" & runNum + 2).Value = Val(txtEnCostSav.Text) oSheet.Range("AO" & runNum + 2).Value = Val(txtNPVEnCostSav.Text) oSheet.Range("AP" & runNum + 2).Value = Val(txtPreRetCO2.Text) oSheet.Range("AQ" & runNum + 2).Value = Val(txtPostRetCO2.Text) oSheet.Range("AR" & runNum + 2).Value = Val(txtPVCO2SavPy.Text) oSheet.Range("AS" & runNum + 2).Value = Val(txt25YCO2sav.Text) oSheet.Range("AT" & runNum + 2).Value = Val(txtEuroPTCO2.Text) oSheet.Range("AU" & runNum + 2).Value = Val(txtNPVTotCost.Text) oSheet.Range("AV" & runNum + 2).Value = Val(txtTotSav2.Text) oSheet.Range("AW" & runNum + 2).Value = Val(txtNetLossGain.Text) oSheet.Range("AX" & runNum + 2).Value = Val(txtPCPayback.Text) oSheet.Range("AY" & runNum + 2).Value = Val(txtCostNeutRentInc.Text) oSheet.Range("AZ" & runNum + 2).Value = Val(txtPCRecov.Text) oBook.save '## only the first one gets save as oBook.close oExcel.quit MsgBox("Your data has been appended to the excel spreadsheet at file location and name " & myPath & " IF YOU OPEN THE FILE TO LOOK AT IT YOU MUST CLOSE IT AGAIN BEFORE ADDING ANOTHER SCENARIO'S DATA") txtRunNum.Text = Val(1 + runNum) End Sub Private Sub Label61_Click(sender As Object, e As EventArgs) Handles Label61.Click MsgBox("You can change this figure depending on how long you think the renovation measures will last. A suggestion is to start with 25 years, then try 30, 35, etc. up to about 50. You can save all the results to a spreadsheet using the button on the bottom right.") End Sub Private Sub Label60_Click(sender As Object, e As EventArgs) Handles Label60.Click MsgBox("For a conservative estimate, enter the number of years the system is guaranteed for. Otherwise, 25 is suggested, but you might like to be more conservative and enter 20.") End Sub Private Sub Label44_Click(sender As Object, e As EventArgs) Handles Label44.Click MsgBox("It is usually best to enter the same number as for expected lifetime of the renovation measures, as the money would not be called upon again untill the next round of renovation.") End Sub Private Sub Label48_Click(sender As Object, e As EventArgs) Handles Label48.Click MsgBox("Enter a realistic amount after carefully checking the web pages of subsidy agencies such as the KfW. Note that these subsidies can be changed or discontinued at short notice.") End Sub Private Sub Label49_Click(sender As Object, e As EventArgs) Handles Label49.Click MsgBox("For the subsidised loan, if any, enter a likely annual interest rate after carefully checking the web pages of subsidy agencies such as the KfW.") End Sub Private Sub Label21_Click(sender As Object, e As EventArgs) Handles Label21.Click End Sub Private Sub Chart1_Click_1(sender As Object, e As EventArgs) Handles Chart1.Click End Sub Private Sub Label46_Click(sender As Object, e As EventArgs) Handles Label46.Click MsgBox("There is no certainty as to what the annual increase in the CO2 tax will be, but it is likely to be low due to political pressure to keep household energy costs affordable.") End Sub Private Sub txtEuroPTCO2_TextChanged(sender As Object, e As EventArgs) Handles txtEuroPTCO2.TextChanged End Sub Private Sub Label70_Click(sender As Object, e As EventArgs) Handles Label70.Click MsgBox("This figure is without discounting. It is the actual energy-efficiency costs (not their net present value) divided by the number of tonnes of CO2 saved over the lifetime of the renovation measures.") End Sub 'Public npvCostOfCO2Saved As Double End Class