• Matthew W. Jackson (unregistered)

    I admire him for DIMing his variables. A lot of lesser programmers would leave Option Explicit turned off and never use those 22 DIM statements.

    I could defend him and say this is more optimized than using arrays...he's avoding some heap allocation and manually unrolling some loops.

    But seriously, what VB programmer would go to that much trouble for a negligable performance gain?

  • Aarrgghh (unregistered)

    Yeah, why didn't he unroll the loop? Jeez, some people...

  • Aarrgghh (unregistered)

    ...the outer loop, I meant. Assume a reasonable maximum size for the table, copy/paste as needed, and throw in a lot of "if rs.EOF goto END" statements.

  • Tim Cartwright (unregistered)
  • TheF0o1 (unregistered)

    Of course, there has to be a better way. Actually, there are many better ways. The real question is: Is there a worse way?

    The count variables really make say WTF. It looks like the programmer ran out of space on one line and figured they had to define a new variable for the next line.

    For me, this gives a completely new meaning to obfuscated code. There's elegant code, which is just the right density. Then there's code so compressed as to be confusing. Now, there's code that appears to be far too diluted. This could be more evidence of being paid based on the number of lines of code.

  • o2bjang (unregistered)

    Why! These people need to understand that regular expressions are our friends

  • RJ (unregistered)

    Well this does make me curious about what the 'stripping' code looks like. Does it just use Replace(), or does it Left + Mid the string and then start all over again with InStr?

    What's that you say about a cat? Oh. right. nevermind...

  • hassan.voyeau@gmail.com (Hassan Voyeau) (unregistered)

    "I could defend him and say this is more optimized than using arrays..."

    Array? Loop? all he needed was one count ...

  • Sean (unregistered)

    There are just some people who are afraid of Regular Expression. My boss complains when I use them, because he doesnt use them enough to remember the syntax of them......

  • Matthew W. Jackson (unregistered)


    As far as I know, VBA does not have any built-in support for Regular Expressions. I know you can use the scripting library, but there's no mention or documentation of it in the built-in VB help.

    Assuming the person knew about regular expressions and didn't like them, I can understand that.

    But personally, I'd rather have a semi-cryptic regular expression in a single line along with 20 lines explaining what it does than 20 lines of code that does the same without regular expressions.

  • David McNett (unregistered)

    I like the optimism of including the two count variables in the aggregation lines. He's just gone to the trouble to set count = 0 but he optimistically includes it in the following line "count = count + test1 (et al)" in the hopes that maybe it's acquired a value magically.

  • Tim Cartwright (unregistered)

    http://royo.is-a-geek.com/iserializable/regulator/ really nice (AND FREE) regular epression syntax builder, plus it even has intellisense...

  • Prakash (unregistered)

    VB programming... easy to learn and misuse by any tom dick and harry.

  • Tim Smith (unregistered)

    I will admit my shame.

    I know about regex. I don't use them enough. I really don't like them due to their highly cryptic nature.

    IMHO, if you need a expression syntax builder, then there is something wrong with the solution.

    But damn, they are powerful and when used properly are the right tool for the job.

  • Steve Wallis (unregistered)

    People's fear of regex is unwarranted.
    Okay, I admit that back when I first saw them I was a little freaked out.
    But the first time I needed to use them, I read the syntax guide for 10 minutes and went 'oh. ok. this is cool.'

    Sure, it might take longer to sit there and code that one line, but damned if its not quicker than writing all that garbage above.

    /bb|[^b]{2}/ - Shakespeare.

  • Cain (unregistered)

    Wow! This is great. The only thing I can fault him on is he hasnt accounted for "N/a" and "n/A".

  • MrGenericCommentGetsInWithTheSpecRemarkAgain (unregistered)

    "Do any of you bitches have the spec?"

  • MrGenericCommentAlsoThinksRegExIsTheBestThingSince (unregistered)

    RegEx's are awesome. Uncommented RegEx's are awesome and scary.

  • MrGenericCommentHasNoticedThat (unregistered)

    ...the maxlength property of the name text box is greater than the actual number of characters you can post.

    Last name was entered as:


  • RayS (unregistered)

    OK, RegExes aside, why bother checking for the presence of +, -, n/A, etc?

    Just do a Replace() without checking first - it does no harm if it's not found, and saves you time checking in the first place. Even without a RegEx you could shrink that function my 80%+.

    What a goon.

  • sloopy (unregistered)

    I'm writing stuff like this before I leave my company

  • Paul Shields (unregistered)

    reminds me of political speaches: long-winded but doesn't say much

  • Reagan (unregistered)

    that code tastes like burning.

  • John Carter (unregistered)

    The jokes in the comments are sometimes too much. My sides hurt on some of the biting sarcasm.

  • foxyshadis (unregistered)

    Regexes are only frightening because they were designed by the same kind of people who find the obfuscated C contest clear and an example of good coding styles. Perl's myriad extensions didn't help that at all.

    Perl 6 will have completely overhauled and entirely new regex syntax, with almost no relationship to the current. It's actually understandable, if a bit more verbose, and I look forward to using it in the future. It should cut down on the quantity of regexes from hell out there.

    Of course, this is besides the point in VB/ASP, with its dirt-simple like regexes. There isn't much excuse for manual string searching anymore, even performance.

  • Distilled Software Hate (unregistered)

    "Perl 6 will have completely overhauled and entirely new regex syntax, with almost no relationship to the current."

    Sweet jumping jesus.

Leave a comment on “There has just got to be a better way ...”

Log In or post as a guest

Replying to comment #:

« Return to Article