• Prime Mover (unregistered)

    eff that

  • LCrawford (unregistered)

    Ctrl-K + D in VB.NET would auto format but not fix this horror.

  • (nodebb)

    Jesus fucking Christ

  • (nodebb)

    To set the Option Strict default setting for new projects When you create a project, the Option Strict setting on the Compile tab is set to the Option Strict setting in the Options dialog box.

    To set Option Strict in this dialog box, on the Tools menu, click Options. In the Options dialog box, expand Projects and Solutions, and then click VB Defaults. The initial default setting in VB Defaults is Off.

  • my name is missing (unregistered)

    VB is a WTF in a box anyway. Add subs to it, and forget Halloween.

  • (nodebb)

    @516052 - please check our "thread" at https://thedailywtf.com/articles/comments/for-mere-mortals, I replied there.

    (others - feel free to ignore this)

  • (nodebb)

    I own a hundred thousand lines of code that looks just like this. However, some of it is the C# version of the exact same horror - the real problem isn't VB, it's what people do with VB.

    The whole return a not-string coerced to string that isn't actually a return is very familiar to me. What makes mine worse is that most of it was written after 2010, and I have two co-workers that constantly sing the praises of the departed mastermind that wrote most of it.

  • Sole Purpose Of Visit (unregistered)

    "Return to Sender -- TypeOf Unknown ..."

  • Richard Brantley (unregistered)

    It is possible to write clean code in Visual Basic and VB.NET, you just don't usually see it. It's like clean, readable code in PERL; it can be done, but most people just don't. The language doesn't encourage it.

    Though any program can be written poorly if the programmer just doesn't care enough.

  • (nodebb)

    I'm not so sure it's possible to write clean code in classic VB. The error handling syntax is too local and requires a lot of boilerplate to do sanely. If you couple it with strict attention to detail and a good code inspection tool, maybe you could get somewhere - but both of those things are the exact opposite of what the people who chose VB wanted in the first place.

    VB.Net, however, is a mostly fine language. The lambda syntax is a bit clunky and parentheses are used for so many things that it can become ambiguous, but the list of fundamental problems is pretty small. Much smaller than javascript's. VB.Net's event handling magic is almost impressive as C#'s yield magic.

  • secrets of the spaces (unregistered)

    Assuming there's no tab/spaces mashup going on, there's likely a special coding going on with the spacing. Origin Story: Dude A - "Dude, stop touching my code!" Dude B, "Ok, amigo, just make all your code two spaces further in than mine so I know whose is whose."

  • JB (unregistered)

    Maurice deserves a ****ing medal for fixing this madness in a few months.

  • Barf4Eva (unregistered)

    Man do I miss VB6 code!

    said no one ever...

  • Worf (unregistered)

    Boo, left out of the store was an important question.

    Did Maurice actually try to FIX the code? Or did they just re-write the thing from scratch?

  • mihi (unregistered)

    In fact, converting True to a String in VB6 (not sure about VB.NET) does not necesarily return "True". I've also seen "Wahr" and "Vrai", depending on the user's locale. This is very cool if your VB6 program decides to "serialize" a list of booleans into a text file, the deserialization code compares the lines with True converted to a String, and a German user shares the serialized file with a French one.

    And the "fix": From the VB runtime (usually installed in SYSTEM32), delete VB6DE.DLL and VB6FR.DLL, so it will fall back to the default English resources.

  • (nodebb)

    Ahhh, the good old "Everyone knows computers use English" school of internationalisation (or should that be internationalization?).

  • (nodebb) in reply to Paddles

    i18n ;-)

  • Jay (unregistered)

    "If goCalendar.effTaxYearByTaxYear(iMPTaxYear, lEffTaxYear) Then

            End If"
    

    They're using a function with a return type, to set the long "lEffTaxYear". What's probably supposed to go in that conditional is some type of error handler.

    "Const sSDATNew As String = "NC""

    This constant is only used in the second SQL statement. Why is it a constant? It's never reused. It's not exposed so it can't be changed even if it were just declared as a string.

    Finally:

    " If dtSysType.Rows.Count > 0 Then obj.Text = dtSysType.Rows(0).Item("MSYSTYPEVALUE1") Else obj.Text = "" End If

          getDefaultPath = True"
    

    They're setting the "obj" parameter which was passed by reference. Since this is the only result (besides returning "true"), this does not need to be done this way. My guess again is not understanding how to use Try-catch blocks or the last line is a stub for some kind of error handler that was never written or ported over.

  • Craig (unregistered) in reply to Jaime

    Re "yield magic", VB also has iterator functions which Yield results. Any C# iterator function can be translated more or less directly into VB.

  • (nodebb)

    Option Explicit should not be thought of as "requiring you to declare variables before you use them". It should be thought of as "enabling you to catch the places where you misspelled a variable name". Not using it is an open invitation to all sorts of mystifying bugs.

Leave a comment on “Subbing for the Subcontractors”

Log In or post as a guest

Replying to comment #:

« Return to Article