Help with loop/GUI Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ThomasPaine
Posts: 25
Joined: 24 Jun 2017, 22:17

Help with loop/GUI

20 Aug 2017, 20:12

I have a loop that does some calculations for every month and presents the information in the GUI. However, I'm trying to present a certain value every 12 months (1 year) in the GUI. I've tried many different things (wrote the code mostly with trial/error).

The specific value I'm interested in is this one: Capitalisation := Capitalisation + HypothequePmt
I need to present that value in the gui every 12 months so I tried

if A_Index = 12
{
Cap1 := capitalisation
}

and then call that variable in the gui.

The relevent code is in the following lines: 104, 105, 164, 165, 252

Ideally I should be able to present the value for many years in a row (year 1, 2, 3, 4, 5...) but also for a specific year (like in this case), let's say, year 57. Thanks!

Edit: I also have a separate question. is there a way to zoom the GUI (like websites using touch screen PC's)

Code: Select all

#NoEnv
SetBatchLines -1
;****************************************************************************************************************************************************************
gui, font, s8
Gui, Add, Button, x219 y60 h20 gclear , Recommencer 
Gui, Add, Text, x14 y71 , Commence le:
Gui, Add, Datetime, x90 y68 w103 h20 vCalandrier gCalculatrice , MMM dd yyyy
Gui, Add, Text, x14 y100 , Amortissement (Ans): 
Gui, Add, Edit, x121 y98 w26 h20 vAmortissement gCalculatrice , 30 
Gui, Add, Text, x150 y100 , =
Gui, Add, Edit, x160 y98 w35 h20 vMois readonly , 360
Gui, Add, Text, x200 y100 , (Mois)
Gui, Add, Text, x14 y170 , Paiement (mo)
Gui, Add, Edit, x81 y168 w80 h20 vPmMensuel readonly right ,
Gui, Add, Text, x167 y170 , x 12 = 
Gui, Add, Edit, x203 y168 w95 h20 vPmAnnuel readonly right ,
Gui, Add, Button, x250 y115 h40 gCalculer , Calculer

;***********************************************************

Gui Add, Text, x14 y5 w120 h23 +0x200, Coût de la propriété:
Gui Add, Edit, x120 y5 w120 h23 vCout gCalculatrice , 0
Gui, Add, Text, x250 y8 w100 c73CE1D vCoutF , = $0

Gui Add, Text, x14 y35 w120 h23 +0x200, Mise de fonds (en `%):
Gui Add, Edit, x120 y35 w120 h23 vMiseFondsP gCalculatrice , 0
Gui, Add, Text, x250 y38 w100 c73CE1D vMiseFondsAF , = $0

Gui, Add, Text, x14 y130 , Taux (`%):
SetFormat, float, 0.4
Gui, Add, Edit, x60 y128 w42 h20 gCalculatrice vTaux , 

Gui Add, Text, x14 y200 w140 h23 +0x200, Revenus brut potentiel ($):
Gui Add, Edit, x145 y202 w60 h23 vRBP gCalculatrice , 0
Gui, Add, Text, x215 y205 w100 c73CE1D vRBPF , = $0

Gui Add, Text, x14 y231 w120 h23 +0x200, Prêt hypothécaire ($):
;~ Gui, Add, Edit, x145 y232 w60 h20 vHypotheque gCalculatrice , 0
Gui, Add, Text, x145 y235 w100 c73CE1D vHypothequeF , = $0

Gui Add, Text, x14 y264 w120 h23 +0x200, Taxes Scolaires ($):
Gui Add, Edit, x145 y265 w60 h23 vTaxeS gCalculatrice , 0
Gui, Add, Text, x215 y268 w100 c73CE1D vTaxeSF , = $0

Gui Add, Text, x14 y296 w120 h23 +0x200, Taxes Municipales ($):
Gui Add, Edit, x145 y297 w60 h23 vTaxeM gCalculatrice , 0
Gui, Add, Text, x215 y300 w100 c73CE1D vTaxeMF , = $0

Gui Add, Text, x14 y327 w120 h23 +0x200, Chauffage ($):
Gui Add, Edit, x145 y328 w60 h23 vChauf gCalculatrice , 0
Gui, Add, Text, x215 y331 w100 c73CE1D vChaufF , = $0

Gui Add, Text, x14 y359 w120 h23 +0x200, Électricité ($):
Gui Add, Edit, x145 y360 w60 h23 vElectr gCalculatrice , 0
Gui, Add, Text, x215 y363 w100 c73CE1D vElectrF , = $0

Gui Add, Text, x14 y389 w120 h23 +0x200, Assurances ($):
Gui Add, Edit, x145 y390 w60 h23 vAssurances gCalculatrice , 0
Gui, Add, Text, x215 y393 w100 c73CE1D vAssurancesF , = $0

Gui Add, Text, x14 y420 w120 h23 +0x200, Concierge ($):
Gui Add, Edit, x145 y421 w60 h23 vConcierge gCalculatrice , 0
Gui, Add, Text, x215 y423 w100 c73CE1D vConciergeF , = $0

Gui Add, Text, x14 y450 w120 h23 +0x200, Entretien ($):
Gui Add, Edit, x145 y451 w60 h23 vEntretien gCalculatrice , 0
Gui, Add, Text, x215 y454 w100 c73CE1D vEntretienF , = $0

Gui Add, Text, x14 y487 w120 h23 +0x200, Mauvaises créances (`%):
Gui Add, Edit, x145 y488 w48 h23 vMauvCreanceP gCalculatrice , 0
Gui, Add, Text, x200 y491 w100 c73CE1D vMauvCreanceAF , = $0

Gui Add, Text, x14 y515 w120 h23 +0x200, Taux d'inoccupation (`%):
Gui Add, Edit, x145 y516 w48 h23 vInocupationP gCalculatrice , 0
Gui, Add, Text, x200 y519 w100 c73CE1D vInocupationAF , = $0

Gui Add, Text, x14 y547 w120 h23 +0x200, Nombre de logements:
Gui Add, Edit, x145 y548 w48 h23 vNbLog gCalculatrice , 0

;~ ******************* resultats ***************

Gui Font, s20 w600 cBlue
Gui Add, Text, x430 y20 w130 h23 +0x200 Center, Resultats
Gui Font

Gui Add, Text, x340 y60 w80 h23, Revenus bruts:
Gui, Add, Text, x420 y60 w100 cBA1FB4 vRBPR readonly,  0

Gui Add, Text, x340 y80 w130 h23, Revenu brut effectif (RBE):
Gui, Add, Text, x475 y80 w100 cBA1FB4 vRBER readonly,  0

Gui Add, Text, x340 y100 w80 h23, Depenses:
Gui, Add, Text, x400 y100 w100 cBA1FB4 vDepensesA readonly,  0

Gui Add, Text, x340 y120 w130 h23, Revenu net d'exploitation:
Gui, Add, Text, x475 y120 w100 cBA1FB4 vRNER readonly,  0

Gui Add, Text, x340 y140 w130 h23, Service annuel de la dette:
Gui, Add, Text, x475 y140 w100 cBA1FB4 vPmAnnuelR readonly,  0

Gui Add, Text, x340 y160 w170 h23, Liquidité générée (avant impôts):
Gui, Add, Text, x500 y160 w100 cBA1FB4 vLiquiditeR readonly,  0

Gui Add, Text, x340 y180 w170 h23, Capitalisation:
Gui, Add, Text, x500 y180 w100 cBA1FB4 vCap1R readonly,  0

;**************************************************************

Gui, Add, ListView, x690 y15 w400 r30 vResultat -readonly grid , #|Date|Versement|Capital|Intérêt|Solde
LV_ModifyCol(1, "28 integer")
LV_ModifyCol(2, "60")
LV_ModifyCol(3, "70 center")
LV_ModifyCol(4, "70 center")
LV_ModifyCol(5, "70 center")
LV_ModifyCol(6, "80 center")
Gui, Show, w1100 h580 center , Calculatrice hypothécaire et d'investissement
return
;****************************************************************************************************************************************************************
clear:
reload
return

Calculatrice:

gui,submit,nohide
SetFormat, float, 0.15

Mois := Amortissement*12
mrt := Taux/1200
SetFormat, float, 0.2
MiseFondsA := Cout*MiseFondsP/100
MiseFondsP := MiseFondsA*100/Cout
MauvCreanceA := RBP*MauvCreanceP/100
MauvCreanceP := MauvCreanceA*100/RBP
InocupationA := RBP*InocupationP/100
InocupationP := InocupationA*100/RBP
RBE := RBP - MauvCreanceA - InocupationA
Hypotheque := Cout - MiseFondsA
DepensesA := (TaxeS + TaxeM + Chauf + Electr + Assurances + Concierge + Entretien)
PmMensuel := Hypotheque * ( mrt / (1 - (1 + mrt) ** -Mois))
DepensesAF := ThousandsSep(DepensesA)
PmMensuelf := ThousandsSep(PmMensuel)
PmAnnuel := PmMensuel * 12
RNE := RBE - DepensesA
Liquidite := RNE - PmAnnuel
PmAnnuelf := ThousandsSep(PmAnnuel) 
DepensesAF := ThousandsSep(DepensesA)
guicontrol,,PmMensuel, %PmMensuelF%
guicontrol,,Mois, %Mois%
guicontrol,,PmAnnuel, %PmAnnuelF%
guicontrol,,DepensesA, %DepensesAF%


setFormat, float, 0.15
CoutF := ThousandsSep(Cout)
guicontrol,,CoutF, = $%CoutF%

MiseFondsAF := ThousandsSep(MiseFondsA)
guicontrol,,MiseFondsAF, = $%MiseFondsAF%

HypothequeZ := ThousandsSep(Hypotheque)
guicontrol,,HypothequeZ, = $%HypothequeZ%

Cap1R := ThousandsSep(Capitalisation)
guicontrol,,Cap1R, = $%Cap1R%

RBPF := ThousandsSep(RBP)
guicontrol,,RBPF, = $%RBPF%

RBPR := ThousandsSep(RBP)
guicontrol,,RBPR, %RBPR%

RBER := ThousandsSep(RBE)
guicontrol,,RBER, %RBER%

RNER := ThousandsSep(RNE)
guicontrol,,RNER, %RNER%

PmAnnuelR := ThousandsSep(PmAnnuel)
guicontrol,,PmAnnuelR, %PmAnnuelR%

LiquiditeR := ThousandsSep(Liquidite)
guicontrol,,LiquiditeR, %LiquiditeR%

Cap1R := ThousandsSep(Cap1)
guicontrol,,Cap1R, %Cap1R%

HypothequeF := ThousandsSep(Hypotheque)
guicontrol,,HypothequeF, = $%HypothequeF%

TaxeSF := ThousandsSep(TaxeS)
guicontrol,,TaxeSF, = $%TaxeSF%

TaxeMF := ThousandsSep(TaxeM)
guicontrol,,TaxeMF, = $%TaxeMF%

ChaufF := ThousandsSep(Chauf)
guicontrol,,ChaufF, = $%ChaufF%

ElectrF := ThousandsSep(Electr)
guicontrol,,ElectrF, = $%ElectrF%

AssurancesF := ThousandsSep(Assurances)
guicontrol,,AssurancesF, = $%AssurancesF%

ConciergeF := ThousandsSep(Concierge)
guicontrol,,ConciergeF, = $%ConciergeF%

EntretienF := ThousandsSep(Entretien)
guicontrol,,EntretienF, = $%EntretienF%

MauvCreanceAF := ThousandsSep(MauvCreanceA)
guicontrol,,MauvCreanceAF, = $%MauvCreanceAF%

InocupationAF := ThousandsSep(InocupationA)
guicontrol,,InocupationAF, = $%InocupationAF%

;~ ************************************* Resultats *************************************

DepensesAF := ThousandsSep(DepensesA)
guicontrol,,DepensesAF, = $%DepensesAF%

;~ *************************************************************************************
HypothequeNew := 0
Cap1 := 0
n := 0

Gui, ListView, Resultat
LV_Delete()
Ndt1:= Calandrier
Ndt:= Calandrier
SetFormat, float, 0.2
loop, %Mois%
 {
 EnvAdd, Ndt1, 28, days
 FormatTime, Calandrierf, %Calandrier%, MM/dd/yyyy
 FormatTime, Ndtm, %Ndt%, MM
 FormatTime, Ndt1m, %Ndt1%, MM
 if Ndtm = %Ndt1m% 
 {
 EnvAdd Ndt1,4,Days
 }
 FormatTime, Ndt2, %Ndt1%, MMM yyyy
 Ndt = %Ndt1%
 
 InteretPmt := Hypotheque*mrt
 HypothequePmt := PmMensuel - InteretPmt
 Hypotheque := Hypotheque - HypothequePmt
 Versement := HypothequePmt + InteretPmt
 Capitalisation := Capitalisation + HypothequePmt
 
 if A_Index = 12
  Cap1 := capitalisation
 
 HypothequePmtf := ThousandsSep(HypothequePmt)
 Hypothequef := ThousandsSep(Hypotheque) 
 InteretPmtf := ThousandsSep(InteretPmt) 
 Versementf := ThousandsSep(Versement)
 LV_Add("",A_Index ,Ndt2, Versementf, HypothequePmtf, InteretPmtf, Hypothequef)
 }
return

Calculer:
i = 1
filedelete %A_ScriptDir%\Calculatrice.htm
fileappend, <html><head><title></title><style type="text/css" media=screen><!--, %a_scriptdir%\Calculatrice.htm
fileappend, body`,td`,H1 {font-family: "segoe ui";text-align: center;font-size: 11pt}, %A_ScriptDir%\Calculatrice.htm
fileappend, // --></style></head>, %A_ScriptDir%\Calculatrice.htm
fileappend, `r`n<body><center><h1>Prêt: %Hypothequez%`; Amortissement: %Amortissement% ans<br>Taux Annuel: %Taux%`%`; Date: %Calandrierf%<br>Paiement Mensuel: $%PmMensuelf%`; Paiement Annuel: $%PmAnnuelf%<br><br></H1></center>, %A_ScriptDir%\Calculatrice.htm
fileappend, `r`n<table align=center border=1 width=70`%>, %A_ScriptDir%\Calculatrice.htm
fileappend, `r`n<tr><h1><td>Paiement<br>#</td><td>Date<br>de paiement</td><td>Capital<br></td><td>Intérêt <br></td><td>Paiement Mensuel<br>Total</td><td>Nouvelle<br>Dette</td></H1></tr>, %A_ScriptDir%\Calculatrice.htm
Gui, ListView, Resultat
loop , %Mois%
 { 
 LV_GetText(prnt1, i , 1) 
 LV_GetText(prnt2, i , 2)
 LV_GetText(prnt3, i , 4)
 LV_GetText(prnt4, i , 5)
 LV_GetText(prnt5, i , 6)
 fileappend, `r`n<tr><td>%prnt1%</td><td>%prnt2%</td><td>%prnt3%</td><td>%prnt4%</td><td>%PmMensuelf%</td><td>%prnt5%</td></tr>, %A_ScriptDir%\Calculatrice.htm
 ++i
 }
fileappend, `r`n</font></table></body></html>, %A_ScriptDir%\Calculatrice.htm
runwait, %A_ScriptDir%\Calculatrice.htm
return

guiclose:
ExitApp
;******************************************************************************************************************************************************************
ThousandsSep(x, s=",") { 
 return RegExReplace(x, "(?(?<=\.)(*COMMIT)(*FAIL))\d(?=(\d{3})+(\D|$))", "$0" s)
}
Rindis
Posts: 213
Joined: 23 Dec 2013, 13:58
Location: Norway
Contact:

Re: Help with loop/GUI

21 Aug 2017, 08:06

What is the problem, does it not calculate the value or does it not update the GUI?

maybe change line 252 to

Code: Select all

 if (A_Index = 12)

ThomasPaine
Posts: 25
Joined: 24 Jun 2017, 22:17

Re: Help with loop/GUI

21 Aug 2017, 11:00

Hi. My guess would be that it doesn't calculate, but don't know for sure.
Rindis
Posts: 213
Joined: 23 Dec 2013, 13:58
Location: Norway
Contact:

Re: Help with loop/GUI

21 Aug 2017, 11:42

I always put a MSGbox to test these things. So I would change this

Code: Select all


if A_Index = 12
  Cap1 := capitalisation
  
to

Code: Select all

if (A_Index = 12)
{
  Cap1 := capitalisation
MsgBox 1 Year, Cap1 = %Cap1%
}
just too check if this part ever is triggered
ThomasPaine
Posts: 25
Joined: 24 Jun 2017, 22:17

Re: Help with loop/GUI

24 Aug 2017, 15:10

Thanks, no, it doesn't work.
Rindis
Posts: 213
Joined: 23 Dec 2013, 13:58
Location: Norway
Contact:

Re: Help with loop/GUI  Topic is solved

25 Aug 2017, 02:06

try this:

Code: Select all

#NoEnv
SetBatchLines -1
#SingleInstance, Force

;****************************************************************************************************************************************************************
gui, font, s8
Gui, Add, Button, x219 y60 h20 gclear , Recommencer 
Gui, Add, Text, x14 y71 , Commence le:
Gui, Add, Datetime, x90 y68 w103 h20 vCalandrier gCalculatrice , MMM dd yyyy
Gui, Add, Text, x14 y100 , Amortissement (Ans): 
Gui, Add, Edit, x121 y98 w26 h20 vAmortissement gCalculatrice , 30 
Gui, Add, Text, x150 y100 , =
Gui, Add, Edit, x160 y98 w35 h20 vMois readonly , 360
Gui, Add, Text, x200 y100 , (Mois)
Gui, Add, Text, x14 y170 , Paiement (mo)
Gui, Add, Edit, x81 y168 w80 h20 vPmMensuel readonly right ,
Gui, Add, Text, x167 y170 , x 12 = 
Gui, Add, Edit, x203 y168 w95 h20 vPmAnnuel readonly right ,
Gui, Add, Button, x250 y115 h40 gCalculer , Calculer

;***********************************************************

Gui Add, Text, x14 y5 w120 h23 +0x200, Coût de la propriété:
Gui Add, Edit, x120 y5 w120 h23 vCout gCalculatrice , 0
Gui, Add, Text, x250 y8 w100 c73CE1D vCoutF , = $0

Gui Add, Text, x14 y35 w120 h23 +0x200, Mise de fonds (en `%):
Gui Add, Edit, x120 y35 w120 h23 vMiseFondsP gCalculatrice , 0
Gui, Add, Text, x250 y38 w100 c73CE1D vMiseFondsAF , = $0

Gui, Add, Text, x14 y130 , Taux (`%):
SetFormat, float, 0.4
Gui, Add, Edit, x60 y128 w42 h20 gCalculatrice vTaux , 

Gui Add, Text, x14 y200 w140 h23 +0x200, Revenus brut potentiel ($):
Gui Add, Edit, x145 y202 w60 h23 vRBP gCalculatrice , 0
Gui, Add, Text, x215 y205 w100 c73CE1D vRBPF , = $0

Gui Add, Text, x14 y231 w120 h23 +0x200, Prêt hypothécaire ($):
;~ Gui, Add, Edit, x145 y232 w60 h20 vHypotheque gCalculatrice , 0
Gui, Add, Text, x145 y235 w100 c73CE1D vHypothequeF , = $0

Gui Add, Text, x14 y264 w120 h23 +0x200, Taxes Scolaires ($):
Gui Add, Edit, x145 y265 w60 h23 vTaxeS gCalculatrice , 0
Gui, Add, Text, x215 y268 w100 c73CE1D vTaxeSF , = $0

Gui Add, Text, x14 y296 w120 h23 +0x200, Taxes Municipales ($):
Gui Add, Edit, x145 y297 w60 h23 vTaxeM gCalculatrice , 0
Gui, Add, Text, x215 y300 w100 c73CE1D vTaxeMF , = $0

Gui Add, Text, x14 y327 w120 h23 +0x200, Chauffage ($):
Gui Add, Edit, x145 y328 w60 h23 vChauf gCalculatrice , 0
Gui, Add, Text, x215 y331 w100 c73CE1D vChaufF , = $0

Gui Add, Text, x14 y359 w120 h23 +0x200, Électricité ($):
Gui Add, Edit, x145 y360 w60 h23 vElectr gCalculatrice , 0
Gui, Add, Text, x215 y363 w100 c73CE1D vElectrF , = $0

Gui Add, Text, x14 y389 w120 h23 +0x200, Assurances ($):
Gui Add, Edit, x145 y390 w60 h23 vAssurances gCalculatrice , 0
Gui, Add, Text, x215 y393 w100 c73CE1D vAssurancesF , = $0

Gui Add, Text, x14 y420 w120 h23 +0x200, Concierge ($):
Gui Add, Edit, x145 y421 w60 h23 vConcierge gCalculatrice , 0
Gui, Add, Text, x215 y423 w100 c73CE1D vConciergeF , = $0

Gui Add, Text, x14 y450 w120 h23 +0x200, Entretien ($):
Gui Add, Edit, x145 y451 w60 h23 vEntretien gCalculatrice , 0
Gui, Add, Text, x215 y454 w100 c73CE1D vEntretienF , = $0

Gui Add, Text, x14 y487 w120 h23 +0x200, Mauvaises créances (`%):
Gui Add, Edit, x145 y488 w48 h23 vMauvCreanceP gCalculatrice , 0
Gui, Add, Text, x200 y491 w100 c73CE1D vMauvCreanceAF , = $0

Gui Add, Text, x14 y515 w120 h23 +0x200, Taux d'inoccupation (`%):
Gui Add, Edit, x145 y516 w48 h23 vInocupationP gCalculatrice , 0
Gui, Add, Text, x200 y519 w100 c73CE1D vInocupationAF , = $0

Gui Add, Text, x14 y547 w120 h23 +0x200, Nombre de logements:
Gui Add, Edit, x145 y548 w48 h23 vNbLog gCalculatrice , 0

;~ ******************* resultats ***************

Gui Font, s20 w600 cBlue
Gui Add, Text, x430 y20 w130 h23 +0x200 Center, Resultats
Gui Font

Gui Add, Text, x340 y60 w80 h23, Revenus bruts:
Gui, Add, Text, x420 y60 w100 cBA1FB4 vRBPR readonly,  0

Gui Add, Text, x340 y80 w130 h23, Revenu brut effectif (RBE):
Gui, Add, Text, x475 y80 w100 cBA1FB4 vRBER readonly,  0

Gui Add, Text, x340 y100 w80 h23, Depenses:
Gui, Add, Text, x400 y100 w100 cBA1FB4 vDepensesA readonly,  0

Gui Add, Text, x340 y120 w130 h23, Revenu net d'exploitation:
Gui, Add, Text, x475 y120 w100 cBA1FB4 vRNER readonly,  0

Gui Add, Text, x340 y140 w130 h23, Service annuel de la dette:
Gui, Add, Text, x475 y140 w100 cBA1FB4 vPmAnnuelR readonly,  0

Gui Add, Text, x340 y160 w170 h23, Liquidité générée (avant impôts):
Gui, Add, Text, x500 y160 w100 cBA1FB4 vLiquiditeR readonly,  0

Gui Add, Text, x340 y180 w170 h23, Capitalisation:
Gui, Add, Text, x500 y180 w100 cBA1FB4 vCap1R readonly,  0

;**************************************************************

Gui, Add, ListView, x690 y15 w400 r30 vResultat -readonly grid , #|Date|Versement|Capital|Intérêt|Solde
LV_ModifyCol(1, "28 integer")
LV_ModifyCol(2, "60")
LV_ModifyCol(3, "70 center")
LV_ModifyCol(4, "70 center")
LV_ModifyCol(5, "70 center")
LV_ModifyCol(6, "80 center")
Gui, Show, w1100 h580 center , Calculatrice hypothécaire et d'investissement
return
;****************************************************************************************************************************************************************
clear:
reload
return

Calculatrice:

gui,submit,nohide
SetFormat, float, 0.15

Mois := Amortissement*12
mrt := Taux/1200
SetFormat, float, 0.2
MiseFondsA := Cout*MiseFondsP/100
MiseFondsP := MiseFondsA*100/Cout
MauvCreanceA := RBP*MauvCreanceP/100
MauvCreanceP := MauvCreanceA*100/RBP
InocupationA := RBP*InocupationP/100
InocupationP := InocupationA*100/RBP
RBE := RBP - MauvCreanceA - InocupationA
Hypotheque := Cout - MiseFondsA
DepensesA := (TaxeS + TaxeM + Chauf + Electr + Assurances + Concierge + Entretien)
PmMensuel := Hypotheque * ( mrt / (1 - (1 + mrt) ** -Mois))
DepensesAF := ThousandsSep(DepensesA)
PmMensuelf := ThousandsSep(PmMensuel)
PmAnnuel := PmMensuel * 12
RNE := RBE - DepensesA
Liquidite := RNE - PmAnnuel
PmAnnuelf := ThousandsSep(PmAnnuel) 
DepensesAF := ThousandsSep(DepensesA)
guicontrol,,PmMensuel, %PmMensuelF%
guicontrol,,Mois, %Mois%
guicontrol,,PmAnnuel, %PmAnnuelF%
guicontrol,,DepensesA, %DepensesAF%


setFormat, float, 0.15
CoutF := ThousandsSep(Cout)
guicontrol,,CoutF, = $%CoutF%

MiseFondsAF := ThousandsSep(MiseFondsA)
guicontrol,,MiseFondsAF, = $%MiseFondsAF%

HypothequeZ := ThousandsSep(Hypotheque)
guicontrol,,HypothequeZ, = $%HypothequeZ%

Cap1R := ThousandsSep(Capitalisation)
guicontrol,,Cap1R, = $%Cap1R%

RBPF := ThousandsSep(RBP)
guicontrol,,RBPF, = $%RBPF%

RBPR := ThousandsSep(RBP)
guicontrol,,RBPR, %RBPR%

RBER := ThousandsSep(RBE)
guicontrol,,RBER, %RBER%

RNER := ThousandsSep(RNE)
guicontrol,,RNER, %RNER%

PmAnnuelR := ThousandsSep(PmAnnuel)
guicontrol,,PmAnnuelR, %PmAnnuelR%

LiquiditeR := ThousandsSep(Liquidite)
guicontrol,,LiquiditeR, %LiquiditeR%

Cap1R := ThousandsSep(Cap1)
guicontrol,,Cap1R, %Cap1R%

HypothequeF := ThousandsSep(Hypotheque)
guicontrol,,HypothequeF, = $%HypothequeF%

TaxeSF := ThousandsSep(TaxeS)
guicontrol,,TaxeSF, = $%TaxeSF%

TaxeMF := ThousandsSep(TaxeM)
guicontrol,,TaxeMF, = $%TaxeMF%

ChaufF := ThousandsSep(Chauf)
guicontrol,,ChaufF, = $%ChaufF%

ElectrF := ThousandsSep(Electr)
guicontrol,,ElectrF, = $%ElectrF%

AssurancesF := ThousandsSep(Assurances)
guicontrol,,AssurancesF, = $%AssurancesF%

ConciergeF := ThousandsSep(Concierge)
guicontrol,,ConciergeF, = $%ConciergeF%

EntretienF := ThousandsSep(Entretien)
guicontrol,,EntretienF, = $%EntretienF%

MauvCreanceAF := ThousandsSep(MauvCreanceA)
guicontrol,,MauvCreanceAF, = $%MauvCreanceAF%

InocupationAF := ThousandsSep(InocupationA)
guicontrol,,InocupationAF, = $%InocupationAF%

;~ ************************************* Resultats *************************************

DepensesAF := ThousandsSep(DepensesA)
guicontrol,,DepensesAF, = $%DepensesAF%

;~ *************************************************************************************
HypothequeNew := 0
Cap1 := 0
n := 0

Gui, ListView, Resultat
LV_Delete()
Ndt1:= Calandrier
Ndt:= Calandrier
SetFormat, float, 0.2
Capitalisation = 0
HypothequePmt = 0
loop, %Mois%
 {
 EnvAdd, Ndt1, 28, days
 FormatTime, Calandrierf, %Calandrier%, MM/dd/yyyy
 FormatTime, Ndtm, %Ndt%, MM
 FormatTime, Ndt1m, %Ndt1%, MM
 if Ndtm = %Ndt1m% 
 {
 EnvAdd Ndt1,4,Days
 }
 FormatTime, Ndt2, %Ndt1%, MMM yyyy
 Ndt = %Ndt1%
 
 InteretPmt := Hypotheque*mrt
 HypothequePmt := PmMensuel - InteretPmt
 Hypotheque := Hypotheque - HypothequePmt
 Versement := HypothequePmt + InteretPmt
 Capitalisation := Capitalisation + HypothequePmt
 ;~ msgbox capitalisation = %capitalisation% `n HypothequePmt = %HypothequePmt%
 if A_Index = 12
  Cap1 := capitalisation

 
 HypothequePmtf := ThousandsSep(HypothequePmt)
 Hypothequef := ThousandsSep(Hypotheque) 
 InteretPmtf := ThousandsSep(InteretPmt) 
 Versementf := ThousandsSep(Versement)
 LV_Add("",A_Index ,Ndt2, Versementf, HypothequePmtf, InteretPmtf, Hypothequef)
 }
return

Calculer:
i = 1
filedelete %A_ScriptDir%\Calculatrice.htm
fileappend, <html><head><title></title><style type="text/css" media=screen><!--, %a_scriptdir%\Calculatrice.htm
fileappend, body`,td`,H1 {font-family: "segoe ui";text-align: center;font-size: 11pt}, %A_ScriptDir%\Calculatrice.htm
fileappend, // --></style></head>, %A_ScriptDir%\Calculatrice.htm
fileappend, `r`n<body><center><h1>Prêt: %Hypothequez%`; Amortissement: %Amortissement% ans<br>Taux Annuel: %Taux%`%`; Date: %Calandrierf%<br>Paiement Mensuel: $%PmMensuelf%`; Paiement Annuel: $%PmAnnuelf%<br><br></H1></center>, %A_ScriptDir%\Calculatrice.htm
fileappend, `r`n<table align=center border=1 width=70`%>, %A_ScriptDir%\Calculatrice.htm
fileappend, `r`n<tr><h1><td>Paiement<br>#</td><td>Date<br>de paiement</td><td>Capital<br></td><td>Intérêt <br></td><td>Paiement Mensuel<br>Total</td><td>Nouvelle<br>Dette</td></H1></tr>, %A_ScriptDir%\Calculatrice.htm
Gui, ListView, Resultat
loop , %Mois%
 { 
 LV_GetText(prnt1, i , 1) 
 LV_GetText(prnt2, i , 2)
 LV_GetText(prnt3, i , 4)
 LV_GetText(prnt4, i , 5)
 LV_GetText(prnt5, i , 6)
 fileappend, `r`n<tr><td>%prnt1%</td><td>%prnt2%</td><td>%prnt3%</td><td>%prnt4%</td><td>%PmMensuelf%</td><td>%prnt5%</td></tr>, %A_ScriptDir%\Calculatrice.htm
 ++i
 }
fileappend, `r`n</font></table></body></html>, %A_ScriptDir%\Calculatrice.htm
runwait, %A_ScriptDir%\Calculatrice.htm
  msgbox capitalisation = %capitalisation% `n Cap1 = %Cap1%
return

esc::
guiclose:
ExitApp
;******************************************************************************************************************************************************************
ThousandsSep(x, s=",") { 
 return RegExReplace(x, "(?(?<=\.)(*COMMIT)(*FAIL))\d(?=(\d{3})+(\D|$))", "$0" s)
}
I think the problem was tha the variable capitalisation wasn't interpreted as a number so I added this in line 235 and 236
ThomasPaine
Posts: 25
Joined: 24 Jun 2017, 22:17

Re: Help with loop/GUI

25 Aug 2017, 19:24

Thanks, it works. Really appreciate it.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 196 guests