When you got your numbers, who needs other types
-
I have being trying to modify a legecy vb com code. First of all, when it is vb you thing nothing can be right. Then you come across something that is shear madness
Public Function UpdateOrderState(ByVal oldState As Long, ByVal newState As Long)
Dim StockDir As Long, StockChange As Boolean
StockChange = TrueSelect Case 10 * oldState + newState
'Case 12, 32 added more options
Case 12, 32, 42, 52, 62, 72
StockDir = -1
'Case 21, 23 added more options
Case 21, 23, 24, 25, 26, 27
StockDir = 1
Case Else
StockChange = False
End SelectIf StockChange Then 'Code removed End If
End Function
What it is doing is that, it is trying to figure out a state change from one to another. All applicable states have values. Now, what if the value of the states change? :mad:
Yusuf May I help you?
-
I have being trying to modify a legecy vb com code. First of all, when it is vb you thing nothing can be right. Then you come across something that is shear madness
Public Function UpdateOrderState(ByVal oldState As Long, ByVal newState As Long)
Dim StockDir As Long, StockChange As Boolean
StockChange = TrueSelect Case 10 * oldState + newState
'Case 12, 32 added more options
Case 12, 32, 42, 52, 62, 72
StockDir = -1
'Case 21, 23 added more options
Case 21, 23, 24, 25, 26, 27
StockDir = 1
Case Else
StockChange = False
End SelectIf StockChange Then 'Code removed End If
End Function
What it is doing is that, it is trying to figure out a state change from one to another. All applicable states have values. Now, what if the value of the states change? :mad:
Yusuf May I help you?
-
I have being trying to modify a legecy vb com code. First of all, when it is vb you thing nothing can be right. Then you come across something that is shear madness
Public Function UpdateOrderState(ByVal oldState As Long, ByVal newState As Long)
Dim StockDir As Long, StockChange As Boolean
StockChange = TrueSelect Case 10 * oldState + newState
'Case 12, 32 added more options
Case 12, 32, 42, 52, 62, 72
StockDir = -1
'Case 21, 23 added more options
Case 21, 23, 24, 25, 26, 27
StockDir = 1
Case Else
StockChange = False
End SelectIf StockChange Then 'Code removed End If
End Function
What it is doing is that, it is trying to figure out a state change from one to another. All applicable states have values. Now, what if the value of the states change? :mad:
Yusuf May I help you?
It's not even doing that much.... All it's doing is checking whether the state changed to/from 2 (Or neither)...
If oldState = newState Then
StockChange = False
Else if oldState = StockStates.WhateverTheHell2Means Then
StockDir = 1
Else if newState = StockStates.WhateverTheHell2Means Then
StockDir = -1
End IfDon't ya just hate legacy code?
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
I have being trying to modify a legecy vb com code. First of all, when it is vb you thing nothing can be right. Then you come across something that is shear madness
Public Function UpdateOrderState(ByVal oldState As Long, ByVal newState As Long)
Dim StockDir As Long, StockChange As Boolean
StockChange = TrueSelect Case 10 * oldState + newState
'Case 12, 32 added more options
Case 12, 32, 42, 52, 62, 72
StockDir = -1
'Case 21, 23 added more options
Case 21, 23, 24, 25, 26, 27
StockDir = 1
Case Else
StockChange = False
End SelectIf StockChange Then 'Code removed End If
End Function
What it is doing is that, it is trying to figure out a state change from one to another. All applicable states have values. Now, what if the value of the states change? :mad:
Yusuf May I help you?
I wonder if you ran code obfuscation on it, would it produce more readable code? :D
-
It's not even doing that much.... All it's doing is checking whether the state changed to/from 2 (Or neither)...
If oldState = newState Then
StockChange = False
Else if oldState = StockStates.WhateverTheHell2Means Then
StockDir = 1
Else if newState = StockStates.WhateverTheHell2Means Then
StockDir = -1
End IfDon't ya just hate legacy code?
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
I have being trying to modify a legecy vb com code. First of all, when it is vb you thing nothing can be right. Then you come across something that is shear madness
Public Function UpdateOrderState(ByVal oldState As Long, ByVal newState As Long)
Dim StockDir As Long, StockChange As Boolean
StockChange = TrueSelect Case 10 * oldState + newState
'Case 12, 32 added more options
Case 12, 32, 42, 52, 62, 72
StockDir = -1
'Case 21, 23 added more options
Case 21, 23, 24, 25, 26, 27
StockDir = 1
Case Else
StockChange = False
End SelectIf StockChange Then 'Code removed End If
End Function
What it is doing is that, it is trying to figure out a state change from one to another. All applicable states have values. Now, what if the value of the states change? :mad:
Yusuf May I help you?
This looks crazy ... but I would not blame the programming language, the original developer of this piece of ... code? ... will write bad code in any language.
-
This looks crazy ... but I would not blame the programming language, the original developer of this piece of ... code? ... will write bad code in any language.
-
I have being trying to modify a legecy vb com code. First of all, when it is vb you thing nothing can be right. Then you come across something that is shear madness
Public Function UpdateOrderState(ByVal oldState As Long, ByVal newState As Long)
Dim StockDir As Long, StockChange As Boolean
StockChange = TrueSelect Case 10 * oldState + newState
'Case 12, 32 added more options
Case 12, 32, 42, 52, 62, 72
StockDir = -1
'Case 21, 23 added more options
Case 21, 23, 24, 25, 26, 27
StockDir = 1
Case Else
StockChange = False
End SelectIf StockChange Then 'Code removed End If
End Function
What it is doing is that, it is trying to figure out a state change from one to another. All applicable states have values. Now, what if the value of the states change? :mad:
Yusuf May I help you?
Every time you add a new state you need to change the code, recompile and release. And if that weren't enough the third time you'd need to rewrite the function to handle a State of 10. Did you add the "Code removed" comment, or is this function actually doing nothing at all?
-
I wonder if you ran code obfuscation on it, would it produce more readable code? :D
:laugh: :thumbsup:
Dave
If this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) -
Every time you add a new state you need to change the code, recompile and release. And if that weren't enough the third time you'd need to rewrite the function to handle a State of 10. Did you add the "Code removed" comment, or is this function actually doing nothing at all?
Jeremy Hutchinson wrote:
Did you add the "Code removed" comment, or is this function actually doing nothing at all?
I did that only for CP. There is some code in that block.
Yusuf May I help you?