Hello Everyone,
I have the following code:
___________________________________________
Function getFee(Symbol, Location, TransactionDate, Quantity, TransactionType)
If TransactionType = "Close Out" Then
getFee = Abs(Quantity) * 0
End If
'Evaluate the 1st symbol by Location and TransactionDate
If Symbol = "A" Or Symbol = "B" Then
Select Case Location
Case "New York"
Select Case TransactionDate
Case DateValue("02/17/05") To DateValue("09/30/05")
getFee = Abs(Quantity) * 0.3
Case DateValue("10/01/05") To DateValue("03/15/15")
getFee = Abs(Quantity) * 0.45
Case Else
getFee = "???"
End Select
Case Location = "Los Angeles"
Select Case TransactionDate
Case DateValue("02/17/05") To DateValue("03/15/15")
getFee = Abs(Quantity) * 0.3
Case Else
getFee = "???"
End Select
End Select
End If
'Evaluate the 2nd symbol by Location and TransactionDate
If Symbol = "C" Then
Select Case Location
Case "New York"
Select Case TransactionDate
Case DateValue("02/17/05") To DateValue("03/15/15")
getFee = Abs(Quantity) * 0.9
Case Else
getFee = "???"
End Select
Case Location = "Los Angeles"
Select Case TransactionDate
Case DateValue("02/17/05") To DateValue("03/15/15")
getFee = Abs(Quantity) * 0.85
Case Else
getFee = "???"
End Select
End Select
End If
End Function
________________________________________
The code above returns a fee based on the location and date of the transaction. Here's the problem:
The code is suppose to return ZERO as the fee when the transaction is a "Close Out". (I tell the code to multiply by 0, thereby rendering the result 0.)
I thought that this snippet of code would do that:
________________________________________
If TransactionType = "Close Out" Then
getFee = Abs(Quantity) * 0
End If
________________________________________
But, the code seems to 'skip' over this section of the code and returns a value regardless of whether the TransactionType is a 'Close Out' of not.
Can someone see what is wrong with the section of the code that is suppose to return the Fee as ZERO if the TransactionType is a 'Close Out'?
Thank you,
Rachel

I have the following code:
___________________________________________
Function getFee(Symbol, Location, TransactionDate, Quantity, TransactionType)
If TransactionType = "Close Out" Then
getFee = Abs(Quantity) * 0
End If
'Evaluate the 1st symbol by Location and TransactionDate
If Symbol = "A" Or Symbol = "B" Then
Select Case Location
Case "New York"
Select Case TransactionDate
Case DateValue("02/17/05") To DateValue("09/30/05")
getFee = Abs(Quantity) * 0.3
Case DateValue("10/01/05") To DateValue("03/15/15")
getFee = Abs(Quantity) * 0.45
Case Else
getFee = "???"
End Select
Case Location = "Los Angeles"
Select Case TransactionDate
Case DateValue("02/17/05") To DateValue("03/15/15")
getFee = Abs(Quantity) * 0.3
Case Else
getFee = "???"
End Select
End Select
End If
'Evaluate the 2nd symbol by Location and TransactionDate
If Symbol = "C" Then
Select Case Location
Case "New York"
Select Case TransactionDate
Case DateValue("02/17/05") To DateValue("03/15/15")
getFee = Abs(Quantity) * 0.9
Case Else
getFee = "???"
End Select
Case Location = "Los Angeles"
Select Case TransactionDate
Case DateValue("02/17/05") To DateValue("03/15/15")
getFee = Abs(Quantity) * 0.85
Case Else
getFee = "???"
End Select
End Select
End If
End Function
________________________________________
The code above returns a fee based on the location and date of the transaction. Here's the problem:
The code is suppose to return ZERO as the fee when the transaction is a "Close Out". (I tell the code to multiply by 0, thereby rendering the result 0.)
I thought that this snippet of code would do that:
________________________________________
If TransactionType = "Close Out" Then
getFee = Abs(Quantity) * 0
End If
________________________________________
But, the code seems to 'skip' over this section of the code and returns a value regardless of whether the TransactionType is a 'Close Out' of not.
Can someone see what is wrong with the section of the code that is suppose to return the Fee as ZERO if the TransactionType is a 'Close Out'?
Thank you,
Rachel