update some monthly form controls

This commit is contained in:
Trowbridge 2019-03-05 17:10:08 -05:00
parent 93a5086160
commit 699d0fbb2e
2 changed files with 119 additions and 11 deletions

130
fpvt.frm
View File

@ -30,15 +30,6 @@ Private Sub cbCancel_Click()
End Sub
Private Sub chbPlug_Change()
opvolume.Enabled = Not chbPlug.value
opprice.Enabled = Not chbPlug.value
End Sub
Private Sub butAdjust_Click()
MsgBox ("adjustment posted")
Me.Hide
@ -48,6 +39,8 @@ Private Sub butCancel_Click()
Me.Hide
End Sub
Private Sub lbMonth_Change()
Dim i As Long
@ -139,6 +132,56 @@ Private Sub opEditVol_Click()
tbFcVol.BackColor = &H80000018
End Sub
Private Sub opEditPriceM_Click()
opmvol.Enabled = False
opmprice.Enabled = False
opmvol.Visible = False
opmprice.Visible = False
opmprice.value = True
opmvol.value = False
tbMFPrice.Enabled = True
tbMFPrice.BackColor = &H80000018
tbMFVal.Enabled = False
tbMFVal.BackColor = &H80000005
tbMFVol.Enabled = False
tbMFVol.BackColor = &H80000005
End Sub
Private Sub opEditSalesM_Click()
opmvol.Enabled = True
opmprice.Enabled = True
opmvol.Visible = True
opmprice.Visible = True
tbMFPrice.Enabled = False
tbMFPrice.BackColor = &H80000005
tbMFVal.Enabled = True
tbMFVal.BackColor = &H80000018
tbMFVol.Enabled = False
tbMFVol.BackColor = &H80000005
End Sub
Private Sub opEditVolM_Click()
opmvol.Enabled = False
opmprice.Enabled = False
opmprice.value = False
opmvol.value = True
opmvol.Enabled = False
opmprice.Enabled = False
opmvol.Visible = False
opmprice.Visible = False
tbMFPrice.Enabled = False
tbMFPrice.BackColor = &H80000005
tbMFVal.Enabled = False
tbMFVal.BackColor = &H80000005
tbMFVol.Enabled = True
tbMFVol.BackColor = &H80000018
End Sub
Private Sub opPlugPrice_Click()
calc_val
End Sub
@ -219,7 +262,6 @@ Private Sub UserForm_Activate()
month(i, 6) = Format(sp("package")("mpvt")(i)("2020 base value_usd"), "#,###")
month(i, 7) = Format(sp("package")("mpvt")(i)("2020 adj value_usd"), "#,###")
month(i, 8) = Format(sp("package")("mpvt")(i)("2020 tot value_usd"), "#,###")
Next i
@ -302,7 +344,7 @@ Sub calc_val()
adjust("user") = Application.UserName
'print json
tbJSON = JsonConverter.ConvertToJson(adjust)
'tbJSON = JsonConverter.ConvertToJson(adjust)
End Sub
@ -345,3 +387,69 @@ Sub calc_price()
End Sub
Sub calc_mval()
Dim pchange As Double
If IsNumeric(tbFcVal.value) Then
'calculate percent change
pchange = CDbl(tbFcVal.value) / (CDbl(tbPadjVal.value) + CDbl(tbBaseVal.value))
'plug the adjustment required
tbAdjVal = Format(CDbl(tbFcVal.value) - CDbl(tbBaseVal.value) - CDbl(tbPadjVal.value), "#,###")
'---------if volume adjustment method is selected, scale the volume up----------------------------------
If opPlugVol Then
tbFcVol = Format((CDbl(tbPadjVol.value) + CDbl(tbBaseVol.value)) * pchange, "#,###")
Else
tbFcVol = Format((CDbl(tbPadjVol.value) + CDbl(tbBaseVol.value)), "#,###")
End If
tbFcPrice = Format(CDbl(tbFcVal.value) / CDbl(tbFcVol.value), "#.000")
tbAdjVol = Format(tbFcVol - (CDbl(tbBaseVol) + CDbl(tbPadjVol)), "#,###")
tbAdjPrice = Format(CDbl(tbFcVal.value) / CDbl(tbFcVol.value) - ((CDbl(tbBaseVal.value) + CDbl(tbPadjVal.value)) / (CDbl(tbBaseVol.value) + CDbl(tbPadjVol.value))), "#.000")
Else
'tbFcVal = Format(CDbl(tbPadjVal.value) + CDbl(tbBaseVal.value), "#,###")
tbAdjVol = Format((CDbl(tbFcVol.value) - CDbl(tbBaseVol.value) - CDbl(tbPadjVol.value)), "#,###")
tbAdjPrice = 0
'tbAdjPrice = Format(CDbl(tbFcVal.value) / CDbl(tbFcVol.value) - ((tbBaseVal + tbPadjVal) / (tbBaseVol + tbPadjVol)), "#.000")
End If
End Sub
Sub calc_mprice()
If IsNumeric(tbFcPrice.value) And tbFcPrice.value <> 0 Then
tbFcVal = Format(CDbl(tbFcPrice.value) * CDbl(tbFcVol.value), "#,###")
tbAdjVal = Format(CDbl(tbFcVal.value) - CDbl(tbBaseVal.value) - CDbl(tbPadjVal.value), "#,###")
tbAdjPrice = Format(CDbl(tbFcVal.value) / CDbl(tbFcVol.value) - ((CDbl(tbBaseVal.value) + CDbl(tbPadjVal.value)) / (CDbl(tbBaseVol.value) + CDbl(tbPadjVol.value))), "#.000")
Else
tbFcVal = 0
tbAdjVal = Format(CDbl(tbFcVal.value) - CDbl(tbBaseVal.value) - CDbl(tbPadjVal.value), "#,###")
End If
End Sub
Sub calc_mvol()
Dim pchange As Double
If IsNumeric(tbFcVol.value) And tbFcVol <> 0 Then
'price should already have been re-calculated to base + prior at this point
tbFcVal = Format(CDbl(tbFcPrice.value) * CDbl(tbFcVol.value))
'calculate percent change
'pchange = CDbl(tbFcVal.value) / (CDbl(tbPadjVal.value) + CDbl(tbBaseVal.value))
'plug the adjustment required
tbAdjVal = Format(CDbl(tbFcVal.value) - CDbl(tbBaseVal.value) - CDbl(tbPadjVal.value), "#,###")
tbAdjVol = Format(tbFcVol - (CDbl(tbBaseVol) + CDbl(tbPadjVol)), "#,###")
tbAdjPrice = Format(CDbl(tbFcVal.value) / CDbl(tbFcVol.value) - ((CDbl(tbBaseVal.value) + CDbl(tbPadjVal.value)) / (CDbl(tbBaseVol.value) + CDbl(tbPadjVol.value))), "#.000")
Else
tbFcVal = 0
tbAdjVal = Format(CDbl(tbFcVal.value) - CDbl(tbBaseVal.value) - CDbl(tbPadjVal.value), "#,###")
tbAdjPrice = Format((tbBaseVal + tbPadjVal) / (tbBaseVol + tbPadjVol), "#.000")
tbAdjVol = Format(-CDbl(tbBaseVol.value) - CDbl(tbPadjVol.value), "#,###")
End If
tbFcVal = Format(tbFcVal, "#,###")
End Sub

BIN
fpvt.frx

Binary file not shown.