1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
| '*******************************
'*Function to update the result*
'*******************************
Private Sub MyUpdate()
Dim TempResult, pin, Volume As Variant
'We convert the entry data
pin = CDblOrNull(PinBox.Value)
Volume = CDblOrNull(VolumeBox.Value)
'We check if all the data are available
TempResult = ConnectorCost(pin, Volume, Platingbox.Value, "TYCO")
If IsNull(TempResult) Then
LabTYCO.Caption = ""
LabMOLEX.Caption = ""
LabACS.Caption = ""
LabJST.Caption = ""
LabFCI.Caption = ""
LabECAFACT.Caption = ""
LabAVERAGE.Caption = ""
Else
TempResult = ConnectorCost(pin, Volume, Platingbox.Value, "TYCO")
LabTYCO.Caption = CStr(Round(TempResult, 2))
TempResult = ConnectorCost(pin, Volume, Platingbox.Value, "MOLEX")
LabMOLEX.Caption = CStr(Round(TempResult, 2))
TempResult = ConnectorCost(pin, Volume, Platingbox.Value, "ACS")
LabACS.Caption = CStr(Round(TempResult, 2))
TempResult = ConnectorCost(pin, Volume, Platingbox.Value, "JST")
LabJST.Caption = CStr(Round(TempResult, 2))
TempResult = ConnectorCost(pin, Volume, Platingbox.Value, "FCI")
LabFCI.Caption = CStr(Round(TempResult, 2))
TempResult = ConnectorCost(pin, Volume, Platingbox.Value, "ECAFACT")
LabECAFACT.Caption = CStr(Round(TempResult, 2))
TempResult = Application.WorksheetFunction.Average(CDblOrNull(LabTYCO.Caption), CDblOrNull(LabMOLEX.Caption), CDblOrNull(LabACS.Caption), CDblOrNull(LabJST.Caption), CDblOrNull(LabFCI.Caption), CDblOrNull(LabECAFACT.Caption))
LabAVERAGE.Caption = CStr(Round(TempResult, 2))
End If
End Sub
'*************************************************
'*Functions to update the result in case of event*
'*************************************************
Private Sub PinBox_Change()
Call MyUpdate
End Sub
Private Sub VolumeBox_Change()
Call MyUpdate
End Sub
Private Sub PlatingBox_Change()
Call MyUpdate
End Sub
'******************************************
'*Function to calculate the connector cost*
'******************************************
Private Function ConnectorCost(ByVal pin, ByVal Volume, ByVal Plating, ByVal Supplier) As Variant
Dim CoefSupplier, CoefVolume, AdderPlating, AdderY, AdderX, VolumeTemp, pin_nb As Variant
On Error GoTo ErrorTag
If IsNull(pin) Or (pin = 0) Or IsNull(Volume) Or (Volume = 0) Or _
(Plating = "") Or (Supplier = "") Then
GoTo ErrorTag
End If
'pin_nb = pin
If Supplier = "TYCO" Then
CoefSupplier = 1.02
ElseIf Supplier = "MOLEX" Then
CoefSupplier = 1.29
ElseIf Supplier = "JST" Then
CoefSupplier = 0.65
ElseIf Supplier = "ACS" Then
CoefSupplier = 0.5
ElseIf Supplier = "FCI" Then
CoefSupplier = 1.1
ElseIf Supplier = "ECAFACT" Then
CoefSupplier = 2.5
Else
CoefSupplier = 0
End If
If Supplier = "TYCO" Then
AdderY = 0.0891
ElseIf Supplier = "MOLEX" Then
AdderY = 0.0962
ElseIf Supplier = "JST" Then
AdderY = 0.0917
ElseIf Supplier = "ACS" Then
AdderY = 0.1297
ElseIf Supplier = "FCI" Then
AdderY = 0.0941
ElseIf Supplier = "ECAFACT" Then
AdderY = 0.1531
Else
AdderY = 0
End If
If Supplier = "TYCO" Then
AdderX = 0.0148
ElseIf Supplier = "MOLEX" Then
AdderX = 0.0198
ElseIf Supplier = "JST" Then
AdderX = 0.0074
ElseIf Supplier = "ACS" Then
AdderX = 0.0029
ElseIf Supplier = "FCI" Then
AdderX = 0.0164
ElseIf Supplier = "ECAFACT" Then
AdderX = 0.0436
Else
AdderX = 0
End If
If Plating = "Gold" Then
AdderPlating = 0.1
Else
AdderPlating = 0
End If
VolumeTemp = Volume * pin
If VolumeTemp < 25000 Then
CoefVolume = 1.08
ElseIf (VolumeTemp >= 25000) And (VolumeTemp <= 100000) Then
CoefVolume = 1.02
ElseIf (VolumeTemp > 100000) And (VolumeTemp < 500000) Then
CoefVolume = 0.97
ElseIf (VolumeTemp >= 500000) And (VolumeTemp < 1000000) Then
CoefVolume = 0.94
ElseIf (VolumeTemp >= 1000000) Then
CoefVolume = 0.85
Else
CoefVolume = 1
End If
ConnectorCost = CoefSupplier * CoefVolume * (pin * AdderX + AdderY) + AdderPlating
ErrorTag:
ConnectorCost = Null
Exit Function
End Function |