change so price and volume edited together

This commit is contained in:
Trowbridge 2019-03-06 01:19:50 -05:00
parent 6ad0c69c33
commit 856c885c44
2 changed files with 48 additions and 32 deletions

View File

@ -41,12 +41,35 @@ End Sub
Private Sub butMAdjust_Click()
End Sub
Private Sub butMCancel_Click()
Me.Hide
End Sub
Private Sub lbMonth_Change()
Dim i As Long
For i = 0 To 12
If lbMonth.Selected(i) Then
If i <> 0 Then
If co_num(month(i, 6), 0) = 0 And co_num(month(i, 2), 0) = 0 Then
tbMBaseVal.value = 0
tbMBaseVol.value = 0
tbmPAVal.value = 0
tbMPAVol.value = 0
tbMFVal.value = 0
tbMFVol.value = 0
tbMBasePrice = 0
tbMFPrice = 0
End If
'------------base-------------------------------------
tbMBaseVal.value = co_num(month(i, 6), 0)
tbMBaseVol.value = co_num(month(i, 2), 0)
@ -83,6 +106,7 @@ Private Sub lbMonth_Change()
End Sub
Private Sub opEditPrice_Click()
opPlugVol.Enabled = False
opPlugPrice.Enabled = False
opPlugVol.Visible = False
@ -94,12 +118,13 @@ Private Sub opEditPrice_Click()
tbFcPrice.BackColor = &H80000018
tbFcVal.Enabled = False
tbFcVal.BackColor = &H80000005
tbFcVol.Enabled = False
tbFcVol.BackColor = &H80000005
tbFcVol.Enabled = True
tbFcVol.BackColor = &H80000018
End Sub
Private Sub opEditSales_Click()
opPlugVol.Enabled = True
opPlugPrice.Enabled = True
opPlugVol.Visible = True
@ -114,42 +139,27 @@ Private Sub opEditSales_Click()
End Sub
Private Sub opEditVol_Click()
opPlugVol.Enabled = False
opPlugPrice.Enabled = False
opPlugPrice.value = False
opPlugVol.value = True
opPlugVol.Enabled = False
opPlugPrice.Enabled = False
opPlugVol.Visible = False
opPlugPrice.Visible = False
tbFcPrice.Enabled = False
tbFcPrice.BackColor = &H80000005
tbFcVal.Enabled = False
tbFcVal.BackColor = &H80000005
tbFcVol.Enabled = True
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
opmvol.value = True
tbMFPrice.Enabled = True
tbMFPrice.BackColor = &H80000018
tbMFVal.Enabled = False
tbMFVal.BackColor = &H80000005
tbMFVol.Enabled = False
tbMFVol.BackColor = &H80000005
tbMFVol.Enabled = True
tbMFVol.BackColor = &H80000018
End Sub
Private Sub opEditSalesM_Click()
opmvol.Enabled = True
opmprice.Enabled = True
opmvol.Visible = True
@ -165,6 +175,7 @@ Private Sub opEditSalesM_Click()
End Sub
Private Sub opEditVolM_Click()
opmvol.Enabled = False
opmprice.Enabled = False
opmprice.value = False
@ -199,7 +210,7 @@ Private Sub tbFcVal_Change()
End Sub
Private Sub tbFcVol_Change()
If opEditVol Then calc_vol
If opEditPrice Then calc_price
End Sub
'--------------------------------monthly buttons--------------------------------------
@ -218,11 +229,10 @@ End Sub
Private Sub tbmfVal_Change()
If opEditSalesM Then calc_mval
tbMFVal.value = Format(CDbl(tbMFVal.value), "#,###")
End Sub
Private Sub tbmfVol_Change()
If opEditVolM Then calc_mvol
If opEditPriceM Then calc_mprice
End Sub
Private Sub UserForm_Activate()
@ -233,8 +243,8 @@ Private Sub UserForm_Activate()
Dim k As Long
Dim ok As Boolean
handler.server = "http://10.56.1.20:3000"
'handler.server = "http://192.168.1.69:3000"
'handler.server = "http://10.56.1.20:3000"
handler.server = "http://192.168.1.69:3000"
Set sp = handler.scenario_package(handler.scenario, ok)
@ -270,6 +280,7 @@ Private Sub UserForm_Activate()
fpvt.tbFcVol.value = Format(CDbl(fpvt.tbBaseVol.value) + CDbl(fpvt.tbPadjVol.value), "#,###")
fpvt.tbFcVal.value = Format(CDbl(fpvt.tbBaseVal.value) + CDbl(fpvt.tbPadjVal.value), "#")
fpvt.tbFcPrice.value = Format(CDbl(fpvt.tbFcVal.value) / CDbl(fpvt.tbFcVol.value), "#.000")
fpvt.tbPadjPrice.value = Format((CDbl(fpvt.tbPadjVal.value) + CDbl(tbBaseVal.value)) / (CDbl(fpvt.tbBaseVol.value) + CDbl(tbPadjVol.value)) - CDbl(tbBaseVal) / CDbl(tbBaseVol), "#.000")
'---------------------------------------populate monthly-------------------------------------------------------
@ -401,9 +412,10 @@ End Sub
Sub calc_price()
If IsNumeric(tbFcPrice.value) And tbFcPrice.value <> 0 Then
tbFcVal = Format(CDbl(tbFcPrice.value) * CDbl(tbFcVol.value), "#,###")
If IsNumeric(tbFcPrice.value) And tbFcPrice.value <> 0 And IsNumeric(tbFcVol.value) And tbFcVol.value <> 0 Then
tbFcVal = Format(CDbl(tbFcPrice.value) * CDbl(tbFcVol.value), "#,##0")
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
@ -419,6 +431,7 @@ Sub calc_mval()
If IsNumeric(tbMFVal.value) Then
'calculate percent change
If (CDbl(tbmPAVal.value) + CDbl(tbMBaseVal.value)) = 0 Then Exit Sub
pchange = CDbl(tbMFVal.value) / (CDbl(tbmPAVal.value) + CDbl(tbMBaseVal.value))
'plug the adjustment required
@ -440,13 +453,16 @@ Sub calc_mval()
tbMAPrice = 0
'tbMAPrice = Format(CDbl(tbMFVal.value) / CDbl(tbMFVol.value) - ((tbMBaseVal + tbMPAVal) / (tbMBaseVol + tbMPAVol)), "#.000")
End If
tbMFVal = Format(tbMFVal, "#,###")
End Sub
Sub calc_mprice()
If IsNumeric(tbMFPrice.value) And tbMFPrice.value <> 0 Then
tbMFVal = Format(CDbl(tbMFPrice.value) * CDbl(tbMFVol.value), "#,###")
If IsNumeric(tbMFPrice.value) And tbMFPrice.value <> 0 And IsNumeric(tbMFVol.value) And tbMFVol.value <> 0 Then
tbMFVal = Format(CDbl(tbMFPrice.value) * CDbl(tbMFVol.value), "#,##0")
tbMAVal = Format(CDbl(tbMFVal.value) - CDbl(tbMBaseVal.value) - CDbl(tbmPAVal.value), "#,###")
tbMAVol = Format(tbMFVol - (CDbl(tbMBaseVol) + CDbl(tbMPAVol)), "#,###")
tbMAPrice = Format(CDbl(tbMFVal.value) / CDbl(tbMFVol.value) - ((CDbl(tbMBaseVal.value) + CDbl(tbmPAVal.value)) / (CDbl(tbMBaseVol.value) + CDbl(tbMPAVol.value))), "#.000")
Else
tbMFVal = 0
@ -476,6 +492,6 @@ Sub calc_mvol()
tbMAPrice = Format((tbMBaseVal + tbmPAVal) / (tbMBaseVol + tbMPAVol), "#.000")
tbMAVol = Format(-CDbl(tbMBaseVol.value) - CDbl(tbMPAVol.value), "#,###")
End If
tbMFVal = Format(tbMFVal, "#,###")
tbMFVol = Format(CDbl(tbMFVol), "#,###")
End Sub

BIN
fpvt.frx

Binary file not shown.