I have some code that will be used with many different combo boxes. The combo boxes will be named cboEquipment0, cboEquipment1, cboEquipment2, etc... I would like to create a function so that I didn't have to write the code for every combo box. Here's my code.
Private Sub cboEquipment0_Click()
'This code will figure the Acres you can cover per hour with the equipment
'selected.
Dim F As Double, S As Integer, W As Integer, EF As Integer
On Error Resume Next
W = InputBox("Enter the width of the equipment.", "Equipment Width"
S = InputBox("Enter the average speed in the field.", "Equipment Speed"
If cboEquipment0 = "Combine" Then
EF = 70
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = "Disk" Then
EF = 85
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = "Field Cultivator" Then
EF = 85
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = "Chisel Plow" Then
EF = 85
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = "Moldboard Plow" Then
EF = 85
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = "Row Crop Cultivator" Then
EF = 80
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = "Drill" Then
EF = 70
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = "Planter" Then
EF = 65
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = "Fertilizer Spreader" Then
EF = 70
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = "Sprayer" Then
EF = 65
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = " " Then
txtEquipment0.Text = ""
End If
End Sub
Private Sub cboEquipment0_Click()
'This code will figure the Acres you can cover per hour with the equipment
'selected.
Dim F As Double, S As Integer, W As Integer, EF As Integer
On Error Resume Next
W = InputBox("Enter the width of the equipment.", "Equipment Width"
S = InputBox("Enter the average speed in the field.", "Equipment Speed"
If cboEquipment0 = "Combine" Then
EF = 70
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = "Disk" Then
EF = 85
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = "Field Cultivator" Then
EF = 85
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = "Chisel Plow" Then
EF = 85
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = "Moldboard Plow" Then
EF = 85
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = "Row Crop Cultivator" Then
EF = 80
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = "Drill" Then
EF = 70
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = "Planter" Then
EF = 65
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = "Fertilizer Spreader" Then
EF = 70
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = "Sprayer" Then
EF = 65
F = (((S * W) * (EF / 100)) / 8.25)
txtEquipment0.Text = F
ElseIf cboEquipment0 = " " Then
txtEquipment0.Text = ""
End If
End Sub