|
mlNumOfSomething = SomeClass.GetSomething(anIDArray())
For lli = 1 To mlNumOfSomething
SomeClass.GetSomeInfo anIDArray(lli), Description:=aDescription
ReDim Preserve msAllAgencies(1 To mlNumOfSomething)
msSomeArray(lli) = aDescription
Next lli
|
|
|
|
|
I guess they won't need to use an obfuscater...
|
|
|
|
|
That is truely awful. Much better would be:
mlNumOfSomething = SomeClass.GetSomething(anIDArray())
lItemToAdd = 0
For lli = 1 To mlNumOfSomething
SomeClass.GetSomeInfo anIDArray(lli), Description:=aDescription
lItemToAdd = lItemToAdd + 1
ReDim Preserve msAllAgencies(1 To lItemToAdd)
msSomeArray(lItemToAdd) = aDescription
Next lli
That way you can add in logic to exclude items.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
|
Aren't you just so glad we are no longer stuck with 80 character coding sheets... If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
Never realized that SQL allows you to place case statements within a join statement, though I guess nothing would syntatically prevent such.
I would highly recommend placing those conversions/etc. into the secondary query being joined (or wrapped in a second query) just to remove the eyebleeding IsNull that trails into the mile long case statements.
|
|
|
|
|
Jeremy Hutchinson wrote: I'm not sure if it's a good or bad thing that I can just forwarded the problem to the original developer.
I think you should hire the original developer if he is not part of your company. Anyone who can handle that monster join is definetly a good asset for the company. I have no smart signature yet...
|
|
|
|
|
That developer does still work here. What I need is someone who is not only smart enough to handle that monster join, but also smart enough not to write it.
At the very least don't write it as one continuous line with no spaces. Throw a little formatting in there.
|
|
|
|
|
Jeremy Hutchinson wrote: Throw a little formatting in there.
I looked, it's still about as appealing as having a limb turned around.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
Jeremy Hutchinson wrote: to handle that monster
Is the monster a manager now? Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep!
|
|
|
|
|
<code>
Private Function SomeCrappyCode(lsDate As String) As Long
On Error GoTo ErrorHandler
Dim llRetval
Dim llPosition As Long
'Updates the US Month Name in SQL Date to Locale
'Month Name in Locale Language
llPosition = InStr(lsDate, "Jan")
If llPosition > 0 Then
lsDate = Left(lsDate, llPosition - 1) & Format(DateSerial(98, 1, 1), "MMM") & right(lsDate, Len(lsDate) - 3)
llRetval = True
Exit Function
End If
'Copy & paste the above code block 11 more times for Feb...December
mlUpdateMonthStringLocale = llRetval
Exit Function
ErrorHandler:
WriteErrorLogEntry Err.number, "SomeCrappyCode", Err.description
Exit Function
Resume
End Function
</code>
|
|
|
|
|
Ingenious solution to the problem indeed. Obviously it'd be better of with a switch statement though Jeroen De Dauw
---
Forums ; Blog ; Wiki
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|
|
I am not sure how it works in VB exactly, but in a normal language this code would alter local variables lsDate and llRetval without affecting the outside world. So, this function does virtually nothing. Am I right?Greetings - Jacek
|
|
|
|
|
in this case, the incoming parameter defaults to "ByRef", lRetVal defaults to Variant, and the return value is only set when the line of code "ThisFunctionName = aValue", so luckily it sets the lsDate param, but the return value is never set 'cause the author was retarded
|
|
|
|
|
Wes Jones wrote: the return value is never set 'cause the author was retarded
...Greetings - Jacek
|
|
|
|
|
Imagine my horror to find the following code style employed in a body of code I've inherited (VBA, hopefully I'll be able to migrate it away)..
I must say though, there's one VB6/VBA feature I stumbled across in code at work today that makes all these pale into insignificance for obfuscation potential. It's our old friend GoSub/Return.
Function MyFunction
' Do some stuff
GoSub CheckRoutine
' Other Stuff
GoTo TheEnd
CheckRoutine:
' More stuff
Return
TheEnd:
' Cleanup
End Function
Refactoring this steaming pile's gonna be fun. (The original function is 250 lines, and oddly, it calls other functions/subs, as well as using GoSub to access "nested" functions).
Last time I saw that pair of keywords actually used in a program dates back to my 2nd computer - the ZX Spectrum. Please reassure me that Microsoft had the good sense to remove these before the advent of VB.NET
|
|
|
|
|
almost gone[^]: EndIf, GoSub, Let, Variant, and Wend are retained as keywords, although they are no longer used in Visual Basic .NET
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Yes, I checked that shortly after posting earlier. Hopefully I won't find similar treasures in the newer code base then.
Same guy seems inordinately fond of empty true-parts of If statements:
If x = 3 Then
Else
' Statements here
End If
and other horrors, I'll try and keep you posted.
|
|
|
|
|
It's ugly, but will be optimised away.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
If you type Wend in Visual Studio in VB code it automatically replaces it with End While. I can't decide whether that's intended to be helpful (we'll fix that for you, sir) or whether it's a subtle nudge (learn the new syntax, dummy!).
I must admit, I always rather liked the Let keyword. It seemed like such a polite way to code. I say, old chap, would you mind terribly letting a = b. Thanks awfully.
|
|
|
|
|
I think the last time I used a Gosub/Return was either on a Commodore 64, or maybe on VAX/VMS BASIC... either way, it was mid '80s....
In this day and age, even with VBA in mind, there is no reason to use that pair of keywords.
Tim
|
|
|
|
|
If Something() Then
lblpnl10(1).Caption = GetCaptionText(10977, lblpnl10(1).Caption)
lblpnl10(0).Caption = GetCaptionText(10978, lblpnl10(0).Caption)
frapnl10(0).Caption = GetCaptionText(10979, frapnl10(0).Caption)
chkKeepOrigRadioName.Caption = GetCaptionText(10980, chkKeepOrigRadioName.Caption)
lblpnl03(14).Caption = GetCaptionText(10981, lblpnl03(14).Caption)
lblpnl03(13).Caption = GetCaptionText(10982, lblpnl03(13).Caption)
Frame12.Caption = GetCaptionText(10983, Frame12.Caption)
Label13.Caption = GetCaptionText(10984, Label13.Caption)
Label5.Caption = GetCaptionText(10985, Label5.Caption)
Label14.Caption = GetCaptionText(10986, Label14.Caption)
Frame9.Caption = GetCaptionText(10987, Frame9.Caption)
chkLogLateShiftEnd.Caption = GetCaptionText(10988, chkLogLateShiftEnd.Caption)
....48 more
End If
|
|
|
|
|
you should order those statements alphabetically; that improves maintainability.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Wow, this guy knows nothing, look at all those magic numbers, how are you meant to know what they mean?
Const Number1 As Int32 = 0
Const Number2 As Int32 = 1
Const Number3 As Int32 = 13
Const Number4 As Int32 = 14
Const Number5 As Int32 = 10977
Const Number6 As Int32 = 10978
Const Number7 As Int32 = 10979
Const Number8 As Int32 = 10980
Const Number9 As Int32 = 10981
Const Number10 As Int32 = 10982
Const Number11 As Int32 = 10983
Const Number12 As Int32 = 10984
Const Number13 As Int32 = 10985
Const Number14 As Int32 = 10986
Const Number15 As Int32 = 10987
Const Number16 As Int32 = 10988
If Something() Then
chkLogLateShiftEnd.Caption = GetCaptionText(Number16, chkLogLateShiftEnd.Caption)
chkKeepOrigRadioName.Caption = GetCaptionText(Number8, chkKeepOrigRadioName.Caption)
Frame9.Caption = GetCaptionText(Number15, Frame9.Caption)
Frame12.Caption = GetCaptionText(Number11, Frame12.Caption)
frapnl10(Number1).Caption = GetCaptionText(Number7, frapnl10(Number1).Caption)
Label13.Caption = GetCaptionText(Number12, Label13.Caption)
Label14.Caption = GetCaptionText(Number14, Label14.Caption)
Label5.Caption = GetCaptionText(Number13, Label5.Caption)
lblpnl03(Number4).Caption = GetCaptionText(Number9, lblpnl03(Number4).Caption)
lblpnl03(Number3).Caption = GetCaptionText(Number10, lblpnl03(Number3).Caption)
lblpnl10(Number2).Caption = GetCaptionText(Number5, lblpnl10(Number2).Caption)
lblpnl10(Number1).Caption = GetCaptionText(Number6, lblpnl10(Number1).Caption)
End If
FTFY (Yes, it is a slow day at work)
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
and they say it's hard to improve upon perfection...
|
|
|
|