There has just got to be a better way ...

« Return to Article
  • Matthew W. Jackson 2004-08-18 13:31
    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. <br> <br>I could defend him and say this is more optimized than using arrays...he's avoding some heap allocation and manually unrolling some loops. <br> <br>But seriously, what VB programmer would go to that much trouble for a negligable performance gain?
  • Aarrgghh 2004-08-18 13:32
    Yeah, why didn't he unroll the loop? Jeez, some people...
  • Aarrgghh 2004-08-18 13:34
    ...the outer loop, I meant. Assume a reasonable maximum size for the table, copy/paste as needed, and throw in a lot of &quot;if rs.EOF goto END&quot; statements.
  • Tim Cartwright 2004-08-18 13:39
    REGEX...REGEX...SCHMEGEX <br> <br><a target="_new" href="http://regexlib.com/Default.aspx">http://regexlib.com/Default.aspx</a> <br><a target="_new" href="http://royo.is-a-geek.com/iserializable/regulator/">http://royo.is-a-geek.com/iserializable/regulator/</a> <br> <br>
  • TheF0o1 2004-08-18 13:56
    Of course, there has to be a better way. Actually, there are many better ways. The real question is: Is there a worse way? <br> <br>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. <br> <br>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. <br>
  • o2bjang 2004-08-18 14:24
    Why! These people need to understand that regular expressions are our friends
  • RJ 2004-08-18 14:32
    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? <br> <br>What's that you say about a cat? Oh. right. nevermind...
  • hassan.voyeau@gmail.com (Hassan Voyeau) 2004-08-18 14:51
    &quot;I could defend him and say this is more optimized than using arrays...&quot; <br> <br>Array? Loop? all he needed was one count ...
  • Sean 2004-08-18 15:29
    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 2004-08-18 16:09
    Reminder: <br> <br>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. <br> <br>Assuming the person knew about regular expressions and didn't like them, I can understand that. <br> <br>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 2004-08-18 16:31
    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 &quot;count = count + test1 (et al)&quot; in the hopes that maybe it's acquired a value magically.
  • Tim Cartwright 2004-08-18 17:25
    <a target="_new" href="http://royo.is-a-geek.com/iserializable/regulator/">http://royo.is-a-geek.com/iserializable/regulator/</a> really nice (AND FREE) regular epression syntax builder, plus it even has intellisense...
  • Prakash 2004-08-18 22:08
    VB programming... easy to learn and misuse by any tom dick and harry.
  • Tim Smith 2004-08-18 22:15
    I will admit my shame. <br> <br>I know about regex. I don't use them enough. I really don't like them due to their highly cryptic nature. <br> <br>IMHO, if you need a expression syntax builder, then there is something wrong with the solution. <br> <br>But damn, they are powerful and when used properly are the right tool for the job. <br>
  • Steve Wallis 2004-08-18 22:25
    People's fear of regex is unwarranted. <br>Okay, I admit that back when I first saw them I was a little freaked out. <br>But the first time I needed to use them, I read the syntax guide for 10 minutes and went 'oh. ok. this is cool.' <br> <br>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. <br> <br> <br>/bb|[^b]{2}/ - Shakespeare. <br> <br>
  • Cain 2004-08-18 23:44
    Wow! This is great. The only thing I can fault him on is he hasnt accounted for &quot;N/a&quot; and &quot;n/A&quot;.
  • MrGenericCommentGetsInWithTheSpecRemarkAgain 2004-08-19 05:09
    &quot;Do any of you bitches have the spec?&quot;
  • MrGenericCommentAlsoThinksRegExIsTheBestThingSince 2004-08-19 05:12
    RegEx's are awesome. Uncommented RegEx's are awesome and scary.
  • MrGenericCommentHasNoticedThat 2004-08-19 05:14
    ...the maxlength property of the name text box is greater than the actual number of characters you can post. <br> <br>Last name was entered as: <br> <br>MrGenericCommentAlsoThinksRegExIsTheBestThingSinceBroadlyEquallyDividedBakedFlourYeastEtcProducts
  • RayS 2004-08-19 06:36
    OK, RegExes aside, why bother checking for the presence of +, -, n/A, etc? <br> <br>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%+. <br> <br>What a goon.
  • sloopy 2004-08-19 08:34
    I'm writing stuff like this before I leave my company
  • Paul Shields 2004-08-19 10:36
    reminds me of political speaches: long-winded but doesn't say much
  • Reagan 2004-08-19 11:24
    that code tastes like burning.
  • John Carter 2004-08-19 12:39
    The jokes in the comments are sometimes too much. My sides hurt on some of the biting sarcasm.
  • foxyshadis 2004-08-19 18:25
    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. <br> <br>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. <br> <br>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 2004-08-25 22:40
    &quot;Perl 6 will have completely overhauled and entirely new regex syntax, with almost no relationship to the current.&quot; <br> <br>Sweet jumping jesus.