ผลลัพธ์ของการคูณ VBA มีค่าเป็น 0
Posted: Thu May 27, 2021 9:46 am
ตามที่แนบมาด้านล่างครับทำไมบรรทัด Efficiency * EquipmentAvia * Quality_rate ถึงมีค่าเป็น 0 ครับทั้งๆ ค่าแต่ละตัวไม่เป็น 0 ครับ
Dim Avitime, Autotime_per, Nettime, Plantime, Unplantime, Operatingtime, Quality_rate, Autotime, Efficiency, Tacttime, EquipmentAvia, Meet_per, Collet_per, Repiar_per, OBA_per As Double
Dim Totalproduct, TOTALNG, PM, Breaktime, Overalleff As Integer
If ComboBox2.Text = "LD Mounter" Then
Meet_per = 0.02
Collet_per = 0.02
Repiar_per = 0.07
OBA_per = 0.03
Tacttime = 2.35
ElseIf ComboBox2.Text = "Burn-in" Then
Meet_per = 0.014
Collet_per = 0.014
Repiar_per = 0.043
OBA_per = 0.014
Tacttime = 2.35
Else
Meet_per = 0.02
Collet_per = 0.021
Repiar_per = 0.071
OBA_per = 0.029
Tacttime = 2.35
End If
If ComboBox3.Text = "No" Then
PM = 0
ElseIf ComboBox3.Text = "Yes" Then
PM = 180
Else
PM = 0
End If
If ComboBox1.Value = "24" Then
Breaktime = 120
ElseIf ComboBox1.Value = "12" Then
Breaktime = 60
Else
Breaktime = 0
End If
'Cal basic time
Avitime = ComboBox1.Value * 60
Plantime = ((Meet_per + Collet_per + Repiar_per + OBA_per) * Avitime) + PM + Breaktime
Autotime_per = TextBox2.Value
Autotime = (Autotime_per * 1440) / 100
Nettime = Avitime - Plantime
Unplantime = Nettime - Autotime
'Operatingtime = Nettime - Unplantime
EquipmentAia = Autotime / Nettime
Totalproduct = TextBox3.Value
TOTALNG = TextBox4.Value
Efficiency = ((Totalproduct * Tacttime) / 60) / Autotime
Quality_rate = (Totalproduct - TOTALNG) / Totalproduct
Overalleff = EquipmentAvia * Efficiency * Quality_rate * 100
emptyRow = WorksheetFunction.CountA(Range("B:B")) + 1
Cells(emptyRow, 1).Value = TextBox1.Value
Cells(emptyRow, 2).Value = ComboBox2.Text
Cells(emptyRow, 3).Value = EquipmentAia
Cells(emptyRow, 4).Value = Efficiency
Cells(emptyRow, 5).Value = Quality_rate
Cells(emptyRow, 6).Value = Efficiency * EquipmentAvia * Quality_rate
Cells(emptyRow, 7).Value = Avitime
Cells(emptyRow, 8).Value = Plantime
Cells(emptyRow, 9).Value = Autotime_per
Cells(emptyRow, 10).Value = Autotime
Cells(emptyRow, 11).Value = Unplantime
Cells(emptyRow, 12).Value = Nettime
Cells(emptyRow, 13).Value = Overalleff
Dim Avitime, Autotime_per, Nettime, Plantime, Unplantime, Operatingtime, Quality_rate, Autotime, Efficiency, Tacttime, EquipmentAvia, Meet_per, Collet_per, Repiar_per, OBA_per As Double
Dim Totalproduct, TOTALNG, PM, Breaktime, Overalleff As Integer
If ComboBox2.Text = "LD Mounter" Then
Meet_per = 0.02
Collet_per = 0.02
Repiar_per = 0.07
OBA_per = 0.03
Tacttime = 2.35
ElseIf ComboBox2.Text = "Burn-in" Then
Meet_per = 0.014
Collet_per = 0.014
Repiar_per = 0.043
OBA_per = 0.014
Tacttime = 2.35
Else
Meet_per = 0.02
Collet_per = 0.021
Repiar_per = 0.071
OBA_per = 0.029
Tacttime = 2.35
End If
If ComboBox3.Text = "No" Then
PM = 0
ElseIf ComboBox3.Text = "Yes" Then
PM = 180
Else
PM = 0
End If
If ComboBox1.Value = "24" Then
Breaktime = 120
ElseIf ComboBox1.Value = "12" Then
Breaktime = 60
Else
Breaktime = 0
End If
'Cal basic time
Avitime = ComboBox1.Value * 60
Plantime = ((Meet_per + Collet_per + Repiar_per + OBA_per) * Avitime) + PM + Breaktime
Autotime_per = TextBox2.Value
Autotime = (Autotime_per * 1440) / 100
Nettime = Avitime - Plantime
Unplantime = Nettime - Autotime
'Operatingtime = Nettime - Unplantime
EquipmentAia = Autotime / Nettime
Totalproduct = TextBox3.Value
TOTALNG = TextBox4.Value
Efficiency = ((Totalproduct * Tacttime) / 60) / Autotime
Quality_rate = (Totalproduct - TOTALNG) / Totalproduct
Overalleff = EquipmentAvia * Efficiency * Quality_rate * 100
emptyRow = WorksheetFunction.CountA(Range("B:B")) + 1
Cells(emptyRow, 1).Value = TextBox1.Value
Cells(emptyRow, 2).Value = ComboBox2.Text
Cells(emptyRow, 3).Value = EquipmentAia
Cells(emptyRow, 4).Value = Efficiency
Cells(emptyRow, 5).Value = Quality_rate
Cells(emptyRow, 6).Value = Efficiency * EquipmentAvia * Quality_rate
Cells(emptyRow, 7).Value = Avitime
Cells(emptyRow, 8).Value = Plantime
Cells(emptyRow, 9).Value = Autotime_per
Cells(emptyRow, 10).Value = Autotime
Cells(emptyRow, 11).Value = Unplantime
Cells(emptyRow, 12).Value = Nettime
Cells(emptyRow, 13).Value = Overalleff