I am working on a program that contains a selection of a train number, and once that train number is selected there are two cars associated with each train number. These numbers will increase sequentially and the car numbers will also increase sequentially.
What I want to be able to do is write a smaller, more efficient, code that can continue without manually adding more code for hundreds of trains, and their associated cars.
Instead of writing an If-elseif-else statement for every train, could I write something that will manually track that?
The code provided is a snippet of what the final code will entail.
What I want to be able to do is write a smaller, more efficient, code that can continue without manually adding more code for hundreds of trains, and their associated cars.
Instead of writing an If-elseif-else statement for every train, could I write something that will manually track that?
The code provided is a snippet of what the final code will entail.
VBA Code:
If txtTrain = "7" Then
If Me.cbxCar = "A" Then
carNumber = "7013"
ElseIf Me.cbxCar = "B" Then
carNumber = "7014"
Else
carNumber = "7013 - 7014"
End If
ElseIf txtTrain = "8" Then
If Me.cbxCar = "A" Then
carNumber = "7015"
ElseIf Me.cbxCar = "B" Then
carNumber = "7016"
Else
carNumber = "7015 - 7016"
End If
ElseIf txtTrain = "9" Then
If Me.cbxCar = "A" Then
carNumber = "7017"
ElseIf Me.cbxCar = "B" Then
carNumber = "7018"
Else
carNumber = "7017 - 7018"
End If
ElseIf txtTrain = "10" Then
If Me.cbxCar = "A" Then
carNumber = "7019"
ElseIf Me.cbxCar = "B" Then
carNumber = "7020"
Else
carNumber = "7019 - 7020"
End If
ElseIf txtTrain = "11" Then
If Me.cbxCar = "A" Then
carNumber = "7021"
ElseIf Me.cbxCar = "B" Then
carNumber = "7022"
Else
carNumber = "7021 - 7022"
End If
ElseIf txtTrain = "12" Then
If Me.cbxCar = "A" Then
carNumber = "7023"
ElseIf Me.cbxCar = "B" Then
carNumber = "7024"
Else
carNumber = "7023 - 7024"
End If
End If