• Jonathan Allen (unregistered) in reply to piptheGeek
    piptheGeek:
    The only thing I have against BASIC is that GOTO should just not exist.

    Goto plays two really important roles.

    First, it gives you access to patterns that VB doesn't support yet. For example, Continue For wasn't available for a long time even though it can really make code cleaner. The same goes for Try-Catch blocks. Goto is the ultimate workaround for limitations in procedural programming.

    Second, there are times when using goto is a lot cleaner than deeply nested if statements or constantly checking a SkipMe flag.

    As VB gets more powerful I find myself using Goto a lot less. However there are still times when one well placed goto can elminate dozens of statments and conditionals.

  • Zylon (unregistered)

    The number of clueless coders in this thread who are confused by BASIC-style "=" handling is truly mind-boggling and disheartening.

    This is what happens when you start newbie programmers out with Java. It warps their fragile little brains.

  • (cs) in reply to Jonathan Allen

    Heh the often hated but misunderstood Goto statement. Tell me what is the difference between these two flavors of VB:

    VB6: On Error Goto ErrorCatch 'Do a bunch of stuff here Goto Cleanup

    ErrorCatch: 'Trap your error here

    Cleanup: 'do your cleanup stuff here

    Vb.Net Try 'Do a bunch of stuff here

    Catch 'Trap your error here

    Finally 'do your cleanup stuff here

    I was using the first one for years in VB6, talk about easy porting of my code over to .Net when it arrived.

  • GSquared (unregistered) in reply to Marcin
    Marcin:
    Nat5an:
    Dave C.:
    rStacey:
    No, the = operator is overloaded for comparision and assignment depending on context.
    A huge WTF right there.

    Meh, SQL does the same thing, as do other languages, I'm sure. It's not that big of a WTF. Just because it's not like C or Java doesn't make it completely crazy.

    Defend this statement. Please show me a valid sql query which has assignment.
    create table Names ( ID int identity primary key, Name varchar(100))

    insert into names (name) select 'Jo'

    update names set name = 'Joe' where name = 'Jo'

    Assignment and comparison, same exact symbol. I'm going to assume from you not knowing that that you've never written an update command in SQL, or you've never written a Where clause.

  • (cs) in reply to GSquared
    GSquared:
    Assignment and comparison, same exact symbol. I'm going to assume from you not knowing that that you've never written an update command in SQL, or you've never written a Where clause.

    I vote for never written a where clause!

    Delete from Table1

  • wiregoat (unregistered) in reply to Mark
    Mark:
    Ow! My EYES!!

    When mom said I'd go blind, she didn't say it would be from looking at too many WTFs!

    No, but it was something similar.

  • levi_h (unregistered)
    try {
        for (String cmd: cmds) {
            try {
                Process p = Runtime.getRuntime ().exec (cmd);
            } catch (Exception ex) {
                if (ex.getMessage ().equals ("Invalid column name 'Result'.")) {
                    if (n == 0) {
                        n ++;
    
                        throw new GotoException ();
                    } else {
                        continue;
                    }
                }
            }
        }
    
        // ...
    } catch (GotoException ex) {}
  • (cs) in reply to MrBester
    MrBester:
    And, lest we forget, it's not that VB([1-6]|\.NET|Script|A)? is a WTF in and of itself, it's the little quirks that make life so much fun that are, such as Stop being a reserved word in VBScript but it doesn't do anything unless you're using it in a [CW]Script context, Escape not being mentioned whatsoever in any VBScript docs ever, but does the same as J(ava)Script's escape(), something set to vbUseDefault is also True (even though the internal value is -2 as against -1 [another WTF there]) or more properly Not(False) so you have to explicitly check instead of just a If variable Then, etc., etc...

    Let me take off my VB fanboy hat and grab a Bashing Bat for a moment...

    Whenever we have a new programmer, chances are they will not know to go into the VB6 configuration option that automatically adds "Option Explicit" to the top of any new module. What is MS thinking by having that option default to "No, let me use random and/or misspelled variable names, thanks"? I suspect it's a sneaky plan to make sure that nobody puts together an Office Killer Application out of VB. :)

    Another VB6 irritant. What should this do?

    Dim Foo, Bar, Baz As Integer

    What it does is dim Baz as Integer. Foo and Bar have no particular place to go, and are defined as Variants. This actually got fixed between VB6 and .NET, though, which would be enough to make me want to upgrade.

    Except for the fact that you can't have control arrays in .NET, which pretty much breaks all the code in the application. I'm sure there's some good reason for getting rid of them, but darned if I can figure it out. Ditto with the elimination of Sub Main. I'm creating any new VB6 applications with a form's Load event as the starting point, but what was wrong with Sub Main? (I suspect y'all will give me the answer soon...)

  • Boudin (unregistered)

    Problem is not to find what'swrong with this code, it's to find what's right... Which is absolutely nothing...

  • Bill (unregistered) in reply to mrprogguy
    mrprogguy:
    Jeff S:
    VB BASHING RULES

    If you'd like to be "witty" and "original" and "clever" and bash VB in a response, you MUST first answer this question before your post:

    If you are forced to use VB.NET (or VB6 or VBA or even VBScript) to write a fairly complex program, would you be able to write code that not only works reliably but that is also clean, maintainable and efficient?

    Answer that question first ( a simple yes or no is fine), and then bash away with your original, witty anti-VB statements.

    (hint: if you say "no", then that says it all about your programming skills -- you are either a pretty horrible programmer, or you don't have sufficient knowledge of VB so you have no business criticizing it. If you say "yes", then you have no business bashing VB because you just demonstrated that it is the programmer, not the language.)

    Thanks!

    No.

    Before you set down the rules under which we can bash VB, you must do the following:

    1. Prove that VB is a language worth using, at all, for anything; and

    2. Eat a can of pork brains, cold.

    Go do a little industry research. Probably more apps used in business over the last 10 years were written in VB than any other Windows language. Some good, some crappy - but it CLEARLY proves that some folks consider it worth using, even if you're not up to the task.

  • Brad (unregistered) in reply to RobertB

    As much as I agree with how bad that code is, I think that it might be nice for some perspective on all the goto comments.

    Basically structured programming has come up with like 10 different ways to do what a goto used to do with one keyword.

    Given they are easier to follow because they are special purpose, they are at their heart just calls to a jmp instruction.

    Let us count the ways.

    Goto of course is a jump. Method calls are jumps. if statements cause a jump. else statements cause a jump continue, break, exit... all jumps loop statements are just glorifed jump statements switch statements return statements try/catch/finally statements and so on and so forth.

    I'm just saying that it is not fair to pick on a certain kind of statement just because it is a goto. It is fair to pick on the fact that it is used incorrectly, as in the example for the wtf. My problem is that most people don't even know when a goto is a good idea, so they complain about it at every opportunity.

    For clarification a goto is a good idea if you are three or more nested levels deep and you want to terminate early. In that case, it can make the code simpler and faster.

    for (int j = 1 to 10) {
      for (int x = 1 to 90) {
       for (int k = -1 to -4) {
         if (good) {
           goto hey;
         }
         if (found) {
           goto done;
         }
       }
       if (good) {
         goto hey;
       }
      }
      hey:
    }
    done:
    
  • ContractorInLivingHell (unregistered) in reply to Scott
    Scott:
    Licky Lindsay:
    Someone enlighten this old-schooler.

    Are you seriously telling me that GOTO has not been removed from the BASIC language in the last 20 years?

    Can you also still PEEK and POKE?

    GOTO is also still in all descendants of C, including C#.

    PEEK and POKE are gone though....

    Remember this one?:

    WAIT -16368, 128

    If you know what that means, I can guarantee you that you are at least 35 years old, probably at least 40. :) What's funny is, I have Googled "WAIT -16368, 128", and guess what-- it's not out there. You'd think it'd be out there on some Apple II tribute site, but no.

  • (cs) in reply to benk
    benk:
    On the other hand, APL uses non-ASCII characters? That's a real wtf.
    Oh, and not just a few, but nearly 2 whole keyboards worth on non-ASCII characters!

    See http://www.users.on.net/~farnik/upload/APL2union.gif for a keyboard layout of APL2.

    Most of these are special operators that don't exist in most other languages; e.g., {iota}x (where x is an integer) returns a 1D array consisting of the integers from 1 to x.

    Many other symbols are more "mathematically pure" versions of operators constructed by compound symbols in other languages. e.g., "not equals" is a single character, and looks like what you write on the blackboard: an equals sign with a slash through.

    The special symbols/operators, and the expression syntax results in extremely dense code. For example, I once wrote a prime number generator (up to some fixed N) in one expression. Mind you, it was horrendously inefficient, but, "cool, one line...".

    If nothing else, the language is fun for mind expansion.

  • pkh (unregistered) in reply to Brad
    Brad:
    I'm just saying that it is not fair to pick on a certain kind of statement just because it is a goto.

    Dijkstra would disagree with you. He was smarter than you are.

    If you're having to do the kind of backflips you discuss in your code snippet to get out of loops, there is something wrong with your code's structure. Adding these gotos isn't going to make your code any better.

    Yes, languages should have a structured way to exit from deep nesting (break from named loop, as in perl, perhaps). But, as any other control structure, even structured breaks will be abused.

  • anonymouse (unregistered) in reply to RobertB

    What is MS thinking having that option default to "No..

    You dance around your own answer. Backwards compatibility. your vb 1.0 does not have to re-written to plug into vb6

    your vb 6.0 needs to be re-written (except for the most trivial of functions) to work in .NET which is based on OO classes and not modules.

    I'm creating any new VB6 applications wtf

  • (cs) in reply to Zylon
    Zylon:
    The number of clueless coders in this thread who are confused by BASIC-style "=" handling is truly mind-boggling and disheartening.

    This is what happens when you start newbie programmers out with Java. It warps their fragile little brains.

    Well, I don't know. "x = 1" always meant assignment in basic algebra to me. Equality (or more specifically equivalence) was expressed, in my day, by an APL-like character with three bars rather than two.

    Which isn't really the point. I hate all this crap in Perl and various other languages that means that you have to consider the context in order to determine the meaning of a terminal/operator/whatever. (Although at least Perl makes some attempt to disambiguate via line-noise.)

    Yes, compilers are just dandy at understanding context. Human beings, on the other hand, are less than perfect at this. Indeed, as the earliest post on this particular sub-topic pointed out, you actually have to understand the left/right associativity of the '=' operator before you can have a clue what the context is -- and who needs that misery?

    This whole (silly) debate does bring up an interesting point, though. If Visual Basic, amongst other languages, is so intent on being ecologically sound with the use of horizontal lines -- I mean, there are tons of crap VB programs out there; we're bound to run out of horizontal lines eventually -- then why not extend the concept further?

    I mean, we surely don't need a different symbol for subtraction and negation. (Look, it's symbolically overloaded, according to context, already!)

    I vote that VB.NET (3 and counting) should define '-' for assignment, equality, negation and subtraction, and dispense with the need for '=' altogether. Judicious use of parentheses should ensure that the context remains clear to the intellectual titans who prefer to write in VB.

    Actually, I don't really see why we need '+', '*' or '/' either. Certainly not for programs such as that shown in the OP.

  • (cs) in reply to RobertB
    RobertB:
    Will:
    Thanks, everyone, for clearing up the comparison/assignment thing and for confirming that my decision not to use VB for anything ever was a good one.
    Why all the VB hate? A poster in a previous discussion summed it up nicely: "A poor workman blames his tools".

    If there's one thing I've learned from this site, it's this: There hasn't been a language developed in which bad code can not be written.

    In fact -- and this ought to give you C elitists indigestion -- I'm currently converting several C-language programs TO Visual Basic. Why? Because they are unmaintainable garbage with constructions that would make Kernighan and Ritchie turn to GOTO for better clarity.

    You use the tool that works best for the job.

    (Proud VB coder since 1992. TRS-80 BASIC before that.)

    I use C and Visual Basic. (And like you, my first language was BASIC on the CoCo2. That was in 1985. I was 8 years old. (Yes, I've been programming as long as some people have been reading.))

    You're spot on - it's the programmer, not the language. I've seen things in C that would make you claw out your eyes with a rusty PIC.

    (My favorites are a pair of global flags named "MISC1" and "MISC2" and a global, all-purpose, pointer called ptr.)

  • (cs) in reply to Andrew
    Andrew:

    Programmer's should KNOW that C is not a typical language, and NOT base their idea of a general programming language on it.

    Ok, I'll bite. WHAT is a "typical" language? And what makes that language any more "typical" than C?

    And how is C "assembler" like?

  • (cs) in reply to Ken
    Ken:
    RobertB:
    (Proud VB coder since 1992. TRS-80 BASIC before that.)
    Oh, a newcomer? :-)

    I don't use any dialect of BASIC anymore, but I used VB1 (before they had source files in text) and VB2. Other dialects, including TRS-80 and AppleSoft, before that. And Dartmouth BASIC before that, starting in late 1971. Anyone else learn from "Basic BASIC"?

    I learned a bit of BASIC in 1980 in college, programming on a mainframe, but don't remember what flavor it was (if I ever knew). I also did a little programming in Apple II BASIC and IBM BASIC for the Apple II (they were different) around that same time. But I remember very little of it, and am primarily trained in C++ (went back for a CS degree in 2000).

  • An apprentice (unregistered) in reply to real_aardvark
    real_aardvark:
    Which isn't really the point. I hate all this crap in Perl and various other languages that means that you have to consider the context in order to determine the meaning of a terminal/operator/whatever. (Although at least Perl makes some attempt to disambiguate via line-noise.)

    Yes, compilers are just dandy at understanding context. Human beings, on the other hand, are less than perfect at this. Indeed, as the earliest post on this particular sub-topic pointed out, you actually have to understand the left/right associativity of the '=' operator before you can have a clue what the context is -- and who needs that misery?

    I second that. In fact I noticed that C-like languages are disturbingly ambiguous when it comes to parentheses:

    • as an indicator of evaluation order: (2+3)*4,
    • as an indicator of function call: foo(37),
    • as irrelevant and irritating syntactic salt: if (x==3)

    So I think it's time we define some new symbols whose meaning wouldn't depend on context:

    • (2+3)*4 => 2+3*4,
    • foo(37) => foo@37@,
    • if (x==3) can stay the same.

    How readable! I'd call this new language WTF++.

  • NateB (unregistered) in reply to Harrow
    what does a good workman say if his tools are essentially shit?

    He builds better tools.

  • (cs) in reply to anonymouse
    anonymouse:
    >> What is MS thinking having that option default to "No..

    You dance around your own answer. Backwards compatibility. your vb 1.0 does not have to re-written to plug into vb6

    your vb 6.0 needs to be re-written (except for the most trivial of functions) to work in .NET which is based on OO classes and not modules.

    I'm creating any new VB6 applications wtf

    Unless, of course, you want to use the serial port. Have fun doing that with VB.NET 2003!

    You can use object-oriented programming in any language you want. I use it on embedded C, for science's sake!

  • (cs) in reply to An apprentice
    An apprentice:
    real_aardvark:
    Which isn't really the point. I hate all this crap in Perl and various other languages that means that you have to consider the context in order to determine the meaning of a terminal/operator/whatever. (Although at least Perl makes some attempt to disambiguate via line-noise.)

    Yes, compilers are just dandy at understanding context. Human beings, on the other hand, are less than perfect at this. Indeed, as the earliest post on this particular sub-topic pointed out, you actually have to understand the left/right associativity of the '=' operator before you can have a clue what the context is -- and who needs that misery?

    I second that. In fact I noticed that C-like languages are disturbingly ambiguous when it comes to parentheses:

    • as an indicator of evaluation order: (2+3)*4,
    • as an indicator of function call: foo(37),
    • as irrelevant and irritating syntactic salt: if (x==3)

    So I think it's time we define some new symbols whose meaning wouldn't depend on context:

    • (2+3)*4 => 2+3*4,
    • foo(37) => foo@37@,
    • if (x==3) can stay the same.

    How readable! I'd call this new language WTF++.

    Here, this will help: 0x0d2C

    May your signals all trap May your references be bounded All memory aligned Floats to ints rounded

    Remember ...

    Non-zero is true ++ adds one Arrays start with zero and, NULL is for none

    For octal, use zero 0x means hex = will set == means test

    use -> for a pointer a dot if its not ? : is confusing use them a lot

    a.out is your program there's no U in foobar and, char (*(*x())[])() is a function returning a pointer to an array of pointers to functions returning char

  • (cs)

    Wow, another APLer in the thread. That doesn't happen very often. I like my left arrows too. x?4. APL is good for expanding the mind all right, though most code more than 5 years old is one big WTF. (For the uninitiated, another oft-used symbol is the right arrow, or branch. APL only got control structures recently.)

    Pascal is the best of the conventional languages over the equality/assignment issue, imo. I'm sure we've all written if(x = 5) a lot in C family languages, and imo it's a failing of the language that it's such an easy mistake to make. At least in C# it's a compiler error because it doesn't produce a bool.

    The obvious WTFs are the checking of the exception message, not using the result set anyway and the use of continue in the last line of the loop. (And a big WTF to the poster who thought that the continue was necessary!)

    VB bashing is rather unnecessary in this case, the code would be just as WTFy in C#.

    LOL @ "throw new GotoException()" example :)

  • Anonymous (unregistered) in reply to Will

    No, it's a comparison operator in Visual Basic. Well, it's both an assignment and a comparison operator; depends on the context.

    For example, "A = 0" is an assignment, whereas "If A = 0" is a comparison.

  • poopdeville (unregistered) in reply to Jeff S
    Jeff S:
    VB BASHING RULES

    If you'd like to be "witty" and "original" and "clever" and bash VB in a response, you MUST first answer this question before your post:

    If you are forced to use VB.NET (or VB6 or VBA or even VBScript) to write a fairly complex program, would you be able to write code that not only works reliably but that is also clean, maintainable and efficient?

    Answer that question first ( a simple yes or no is fine), and then bash away with your original, witty anti-VB statements.

    (hint: if you say "no", then that says it all about your programming skills -- you are either a pretty horrible programmer, or you don't have sufficient knowledge of VB so you have no business criticizing it. If you say "yes", then you have no business bashing VB because you just demonstrated that it is the programmer, not the language.)

    Thanks!

    The same could be said of machine code or ASM. Just because something is possible in principle possible doesn't mean it's easy, desireable, or efficient.

    Still, I have no position regarding VB. I fall into the "No, I don't know VB, ASM, or machine code". Use the right tool for the job, etc. My job doesn't involve Windows, and requires portability.

    But is VB really the right tool for any job? I mean, I can understand why someone would choose C over Ruby, or ASM over C. Or even the need to use machine code over ASM. What does VB offer over C#?

  • (cs) in reply to RobertB
    RobertB:
    MrBester:
    And, lest we forget, it's not that VB([1-6]|\.NET|Script|A)? is a WTF in and of itself, it's the little quirks that make life so much fun that are, such as Stop being a reserved word in VBScript but it doesn't do anything unless you're using it in a [CW]Script context, Escape not being mentioned whatsoever in any VBScript docs ever, but does the same as J(ava)Script's escape(), something set to vbUseDefault is also True (even though the internal value is -2 as against -1 [another WTF there]) or more properly Not(False) so you have to explicitly check instead of just a If variable Then, etc., etc...

    Let me take off my VB fanboy hat and grab a Bashing Bat for a moment...

    Whenever we have a new programmer, chances are they will not know to go into the VB6 configuration option that automatically adds "Option Explicit" to the top of any new module. What is MS thinking by having that option default to "No, let me use random and/or misspelled variable names, thanks"? I suspect it's a sneaky plan to make sure that nobody puts together an Office Killer Application out of VB. :)

    Another VB6 irritant. What should this do?

    Dim Foo, Bar, Baz As Integer

    What it does is dim Baz as Integer. Foo and Bar have no particular place to go, and are defined as Variants. This actually got fixed between VB6 and .NET, though, which would be enough to make me want to upgrade.

    Except for the fact that you can't have control arrays in .NET, which pretty much breaks all the code in the application. I'm sure there's some good reason for getting rid of them, but darned if I can figure it out. Ditto with the elimination of Sub Main. I'm creating any new VB6 applications with a form's Load event as the starting point, but what was wrong with Sub Main? (I suspect y'all will give me the answer soon...)

    I got pissed off at that too. Solution: Global module with this function (C# version):

    private Control ByName(string name) { return this.Controls.Find(name, false)[0]; }

    And call everything with ByName("txttracks" + i).Text etc. No, they're not real control arrays, but it was the best alternative I came up with in a hurry. Unless anyone here has better.

  • (cs) in reply to Jojosh_the_Pi
    Jojosh_the_Pi:
    I'm not quite sure what the big deal is about overloading = is. Sure, I prefer the C-like == vs =, but it's not like the statement If a = b Then a = 2 is going to confuse a whole lot of people.
    The really fun part is when you're hunting for an obscure bug and come across if(x=c) { in someone else's C. A light bulb goes off, you change it to ==, start testing, and sudden it start crashing, because he really did want to both assign and test at the same time.

    Why people blame VB when as far as I know there's no IOVBCC I don't know. (Not that I like it much, its default libraries are terrible before .Net, and that's where The Real WTF(tm) comes from.)

    cowbert:
    Uhm, there is no real(tm) exception handling in VB. So using goto to write an exception handler is perfectly fine.
    I like how you make this claim with a straight face, when the goto is right in the middle of a Try block.
    GeneWitch:
    Peeking would have been a lot more useful if you could have coded multithreaded applications... have a flag that is true if the thread is done, false if it isnt, have the main logic peek the flag's location to see its value, then you know if it is done or not. but alas, no multithreading.
    VB has supported threading since VB5 iirc, if not in an elegant or easy way, but .Net cleaned most of that up. But yeah, threading (or rpc) is a liiiiiittle more complex than that. Please study the topic before coming up with neato custom methods of performing thread synchronization!
    Licky Lindsay:
    Scott:
    GOTO is also still in all descendants of C, including C#. PEEK and POKE are gone though....
    Weird. If Java doesn't need GOTO, why does C# ?
    To keep this site in business, obviously.
  • Joseph Newton (unregistered) in reply to Marcin
    Marcin:
    Nat5an:
    Dave C.:
    rStacey:
    No, the = operator is overloaded for comparision and assignment depending on context.
    A huge WTF right there.

    Meh, SQL does the same thing, as do other languages, I'm sure. It's not that big of a WTF. Just because it's not like C or Java doesn't make it completely crazy.

    Defend this statement. Please show me a valid sql query which has assignment.

    update thingamajig set whatsit = 'whosays' where whosit = 'me';

    Given a table thingamajig with varchar columns whatsit and whosit, this is perfectly valid SQL, using the equals sign in different ways based on context. Though I love the C language for its type-specificity, have always thought K&R pulled a big WTF in using the traditional equality sign as an assignment operator. Pascal did it right [at least in this regard, using the much more intuitive := for assignment.

  • Dennis (unregistered)

    I don't see what is it supposed to be but surely it will be something visual and not to do with the programming content?

    http://en.wikipedia.org/wiki/Rorschach_inkblot_test

  • Jens (unregistered)

    Speaking of stupid VB behaviour... This is a classic one. Let's say I have a thingamob that I want to perform operations on, but only when physically connected and it's not busy. The C++ code would be something like:

    if (thingamob.IsConnected() && thingamob.IsBusy() == false) { thingamob.DoSomething(); }

    While as the VB code would be (might be some mistake here, used it 1998 the last time):

    If thingamob.IsConnected And thingamob.IsBusy = False Then thingamob.DoSomething End If

    Not that different, right? Yeah, except for the evaluation. The C++ code sees that the thingamob isn't connected, and moves on. The VB code sees that it isn't connected, but have to check if it's busy "just in case". Which leads the system to do silly things, since the IsBusy() method was written by an incompetent idiot who didn't have any safeguards at all in his code.

    Yes, you can develop pretty big applications in VB. Yes, I have seen some big VB apps. No, it's not possible to maintain them. Every single one of them have been perverse lumps of code filled with lying comments, variable names that are plain wrong, horribly inefficient code...

    It actually does seem like if you design a language that an idiot can use, only idiots will use it. And with that, I'll have to return to my embedded C++ code here...

  • (cs) in reply to RobertB
    RobertB:
    MrBester:
    And, lest we forget, it's not that VB([1-6]|\.NET|Script|A)? is a WTF in and of itself, it's the little quirks that make life so much fun that are, such as Stop being a reserved word in VBScript but it doesn't do anything unless you're using it in a [CW]Script context, Escape not being mentioned whatsoever in any VBScript docs ever, but does the same as J(ava)Script's escape(), something set to vbUseDefault is also True (even though the internal value is -2 as against -1 [another WTF there]) or more properly Not(False) so you have to explicitly check instead of just a If variable Then, etc., etc...

    Let me take off my VB fanboy hat and grab a Bashing Bat for a moment...

    Whenever we have a new programmer, chances are they will not know to go into the VB6 configuration option that automatically adds "Option Explicit" to the top of any new module. What is MS thinking by having that option default to "No, let me use random and/or misspelled variable names, thanks"? I suspect it's a sneaky plan to make sure that nobody puts together an Office Killer Application out of VB. :)

    Another VB6 irritant. What should this do?

    Dim Foo, Bar, Baz As Integer

    What it does is dim Baz as Integer. Foo and Bar have no particular place to go, and are defined as Variants. This actually got fixed between VB6 and .NET, though, which would be enough to make me want to upgrade.

    Except for the fact that you can't have control arrays in .NET, which pretty much breaks all the code in the application. I'm sure there's some good reason for getting rid of them, but darned if I can figure it out. Ditto with the elimination of Sub Main. I'm creating any new VB6 applications with a form's Load event as the starting point, but what was wrong with Sub Main? (I suspect y'all will give me the answer soon...)

    Sub Main is still there, but not when you're doing windows forms. The entry point of the application on a windows form is the startup of the windows form itself. So you'd have your imports statements, and then your module name, all of your global constants and enums and stuff, (just like a console app) and then rather than sub main, you have "form_load" or whatever. Because that's the entry point to the app. So you'd seed your random number generator, get some user input (if need be), read in preferences, etc.

    tell VS to start a new project and pick "console" as the type... Module Module1 Sub Main() End Sub End Module

  • (cs) in reply to foxyshadis

    [quote user="foxyshadis"]VB has supported threading since VB5 iirc, if not in an elegant or easy way, but .Net cleaned most of that up. But yeah, threading (or rpc) is a liiiiiittle more complex than that. Please study the topic before coming up with neato custom methods of performing thread synchronization! [quote]

    Look, dude/lady, i wasn't coming up with neato custom methods. i know how complex threading is. I was merely saying that Peeking (overall) wasn't that useful to me as a programmer. Occasionally i would peek and poke values, but it wasn't for anything spectacular... I was also about 7 years old. So... Forgive me my trespasses.

    Addendum (2007-03-03 07:42): Effed the quote up, should be like: [quote user="foxyshadis"]VB has supported threading since VB5 iirc, if not in an elegant or easy way, but .Net cleaned most of that up. But yeah, threading (or rpc) is a liiiiiittle more complex than that. Please study the topic before coming up with neato custom methods of performing thread synchronization! [/quote]

  • (cs) in reply to AssimilatedByBorg
    AssimilatedByBorg:
    benk:
    On the other hand, APL uses non-ASCII characters? That's a real wtf.
    snip

    The special symbols/operators, and the expression syntax results in extremely dense code. For example, I once wrote a prime number generator (up to some fixed N) in one expression. Mind you, it was horrendously inefficient, but, "cool, one line...".

    If nothing else, the language is fun for mind expansion.

    I'll drink to that. (IOW, i can think of better ways to expand my mind)

  • drtimhill (unregistered)

    Anyone else notice that if the exception message is NOT the specified text then this code will silently all ALL others exceptions of any type that are thrown? Thats pretty WTF in my book too.

  • Kris (unregistered) in reply to Jeff S

    Actually, i probably would be capable of using VB to do usefull stuff, but i still don't like it. Mainly because all IDE's i've used with it (pre .net) sucked bigtime, plus the whole verbosity of the language gets me pounding the keyboard more than i should in a hurry.

    You won't hear me bashing the languge though, that's just distastefull.

  • Joseph Newton (unregistered) in reply to mrprogguy
    mrprogguy:

    No.

    Before you set down the rules under which we can bash VB, you must do the following:

    1. Prove that VB is a language worth using, at all, for anything; and

    2. Eat a can of pork brains, cold.

    I'll pass on the second condition, since I'm a vegetarian, and also since I don't feel particularly subject to conditions that presuppose a judgement.

    On the first condition, I will simply point out a few things:

    1. One of the essential dicta of modern systems development is that you should not re-invent the wheel, unless you have genuine improvements to offer in the basic design. The reality is that a whole lot of the functionality of current computer usage lies in the GUI.

    While VB may not be terribly portable, within its target platform it is probably the most straightforward WYSIWYG GUI builder. This means that as a developer one is freed to focus largely on business logic of the application, without having to futz around with the minutae of presentation implementation.

    1. Visual Basic does not in any way box the developer into using VB alone as a language tool. Since at least VS 6, VB has had facilities for using objects created in other languages by creating DLLs and calling the methods offered from VB. This means that you can very easily relegate logic-intensive tasks to C or C++, while enjoying the strengths of VB functionality.

    Frankly, I am a bit ill at ease defending any Microsoft product. I have a lot of reservations about the ethics of that corporation, and I deplore some of the tricks they have pulled that disempower their users. Nevertheless, I even more deplore prejudice and mindless put-downs, and a lot of the comments I see concerning VB have nothing whatsoever to do with experience in using the tool, and constitute a basically apelike repetition of the prejudices expressed by others.

  • brendan (unregistered)

    The thing I hate about VB is it's syntax. the only consistent thing about the VB syntax is it's inconsistenty. For example you can declare a a variable, or you can just set it to the appropriated value (without declaring a type). Also because the lanaguage is case incensitive, AA and aa mean the same thing.

    To set a variable to an object you have to use the set keyword, but to set it to a built-in type don't have to use it.

    The following lines all do the same thing.

    Proc "param"
    Proc ("param")
    call Proc("param")
    

    Another thing I hate is not that it's not portable, the client system must have a dll(s), so it's not even portable to across windows platforms.

    I could go on for hours.

  • Perseid (unregistered)

    If you're wondering how far back VB in VS 2005 will let you go, I just tested this lovely bit of code:

    Module Module1

    Sub Main()
    

    5: Dim a 10: Console.WriteLine(a) 20: a = a + 1 30: GoTo 10 End Sub

    End Module

    Works just fine. Scary. :)

  • (cs) in reply to Jens
    Jens:
    While as the VB code would be (might be some mistake here, used it 1998 the last time):

    If thingamob.IsConnected And thingamob.IsBusy = False Then thingamob.DoSomething End If

    Not that different, right? Yeah, except for the evaluation. The C++ code sees that the thingamob isn't connected, and moves on. The VB code sees that it isn't connected, but have to check if it's busy "just in case". Which leads the system to do silly things, since the IsBusy() method was written by an incompetent idiot who didn't have any safeguards at all in his code.

    Well, if you know that your program relys on the short-circuiting behaviour, then that VB code is not really equivalent... The appropriate code would be:

    If thingamob.IsConnected Then
        If thingamob.IsBusy = False Then
            thingamob.DoSomething
        End If
    End If
    

    Which is not less readable, clearly indicates the short-circuit behaviour and allows you to have much more specific error messages if you need them:

    If thingamob.IsConnected Then
        If thingamob.IsBusy = False Then
            thingamob.DoSomething
        Else
            Debug.Print "Skipping DoSomething because thingamob Is Busy..."
        End If
    Else
        Debug.Print "Skipping DoSomething because thingamob is not Connected..."
    End If
    
    Jens:
    It actually does seem like if you design a language that an idiot can use, only idiots will use it. And with that, I'll have to return to my embedded C++ code here...

    The way I look at it: there are far more idiots in the world than anything else (except possibly insects, but that's debatable...) So if you design a language which idiots can use, their junk will drown out even the most dedicated senible programmer's contributions....

  • operagost (unregistered) in reply to gruckiii

    Clearly, it's a Klingon Bird of Prey. I've definitely seen worse ASCII art.

  • Joseph Newton (unregistered) in reply to brendan
    brendan:
    The thing I hate about VB is it's syntax. the only consistent thing about the VB syntax is it's inconsistenty. For example you can declare a a variable, or you can just set it to the appropriated value (without declaring a type). Also because the lanaguage is case incensitive, AA and aa mean the same thing.

    To set a variable to an object you have to use the set keyword, but to set it to a built-in type don't have to use it.

    The following lines all do the same thing.

    Proc "param"
    Proc ("param")
    call Proc("param")
    

    Another thing I hate is not that it's not portable, the client system must have a dll(s), so it's not even portable to across windows platforms.

    I could go on for hours.

    Then you must really hate C++, since it was designed with the intent of doing the same thing as this flexibility in VB syntax. In an interview with the IEEE some years ago, [the real one, not the earlier hoax] Dr. Bjarne Stroustrup, the creator of C++, made the point that C++ was not designed to be an "object-oriented" language exclusively, but rather one that supported a wide range of programming styles, object oriented being one of them.

    This doesn't mean that there should not be coding standards within any particular organization, and certainly any development project that uses contributed code or modules could benefit by having clearly-defined interfaces as well as coding and style standards. The point is that the best of programmers don't get stuck in the box of "one way to do it".

  • (cs) in reply to Joseph Newton
    Joseph Newton:
    brendan:
    The thing I hate about VB is it's syntax. the only consistent thing about the VB syntax is it's inconsistenty. For example you can declare a a variable, or you can just set it to the appropriated value (without declaring a type). Also because the lanaguage is case incensitive, AA and aa mean the same thing.

    To set a variable to an object you have to use the set keyword, but to set it to a built-in type don't have to use it.

    The following lines all do the same thing.

    Proc "param"
    Proc ("param")
    call Proc("param")
    

    Another thing I hate is not that it's not portable, the client system must have a dll(s), so it's not even portable to across windows platforms.

    I could go on for hours.

    Then you must really hate C++, since it was designed with the intent of doing the same thing as this flexibility in VB syntax. In an interview with the IEEE some years ago, [the real one, not the earlier hoax] Dr. Bjarne Stroustrup, the creator of C++, made the point that C++ was not designed to be an "object-oriented" language exclusively, but rather one that supported a wide range of programming styles, object oriented being one of them.

    This doesn't mean that there should not be coding standards within any particular organization, and certainly any development project that uses contributed code or modules could benefit by having clearly-defined interfaces as well as coding and style standards. The point is that the best of programmers don't get stuck in the box of "one way to do it".

    I understand what you mean, but this is the point I'm getting at, All of VB's features seem to just be a quick and dirty hack of the original BASIC language. where as C++'s features seem to be incorporated as part of the language.

    Addendum (2007-03-04 04:29):

    Joseph Newton:
    brendan:
    The thing I hate about VB is it's syntax. the only consistent thing about the VB syntax is it's inconsistenty. For example you can declare a a variable, or you can just set it to the appropriated value (without declaring a type). Also because the lanaguage is case incensitive, AA and aa mean the same thing.

    To set a variable to an object you have to use the set keyword, but to set it to a built-in type don't have to use it.

    The following lines all do the same thing.

    Proc "param"
    Proc ("param")
    call Proc("param")
    

    Another thing I hate is not that it's not portable, the client system must have a dll(s), so it's not even portable to across windows platforms.

    I could go on for hours.

    Then you must really hate C++, since it was designed with the intent of doing the same thing as this flexibility in VB syntax. In an interview with the IEEE some years ago, [the real one, not the earlier hoax] Dr. Bjarne Stroustrup, the creator of C++, made the point that C++ was not designed to be an "object-oriented" language exclusively, but rather one that supported a wide range of programming styles, object oriented being one of them.

    This doesn't mean that there should not be coding standards within any particular organization, and certainly any development project that uses contributed code or modules could benefit by having clearly-defined interfaces as well as coding and style standards. The point is that the best of programmers don't get stuck in the box of "one way to do it".

    I understand what you mean, but this is the point I'm getting at, All of VB's features seem to just be a quick and dirty hack of the original BASIC language. where as C++'s features seem to be incorporated as part of the language.

    I'm not saying that I would never use VB. What I am saying, is that I dislike the language for what I have stated above

  • Caleb (unregistered) in reply to Bob Janova

    At work I work in both VB.net and C#. The only times I have ever written something like "if(x = 5)" instead of "If(x == 5) is when I have switched languages within the last couple of hours.

  • Anon (unregistered) in reply to Bill
    Bill:
    Go do a little industry research. Probably more apps used in business over the last 10 years were written in VB than any other Windows language. Some good, some crappy - but it CLEARLY proves that some folks consider it worth using, even if you're not up to the task.
    And a lot of people can bash a rusty nail into a piece of wood with a shoe, but the guy who's building my house better have some high quality tools and know how to use them.

    A poor worker blames his tools, but a good worker doesn't start off by mucking around with poor substitutes for good tools, and thus doesn't need to blame the poor work on the actual shortcomings of the tools.

    The fact that it's possible to do something doesn't prove that its a wise thing to do.

  • noxa (unregistered)

    I totally see a hand giving me the finger. Makes me want to see if I can restructure some of my code to do that ;)

  • (cs) in reply to GeneWitch
    GeneWitch:
    you can't peek and poke in basic anymore, but you can peek and poke in C and C++

    & and * That's peekin and pokin, folks.

    Except i don't know if you can peek arbitrary values (probably, though)

    Actually you probably could. However, on modern architectures, there's little point as peeking or poking anywhere other than where you already have a variable will probably just crash your app. But you still can put arbitrary addresses into a pointer. Plus your compiler complains about converting nonpointer to pointer (which you have to do to pull this off).

    This code assumes an x86 architecture. Obviously having fun with pointers like this isn't portable. You will also have to silence the compiler complaints.

    char* ptr = 0;
    ptr = (char*)47; // Raw address 47 (probably).
    *ptr = 4; // POKE 47, 4
    prtinf("%d", (int)*ptr); // PEEK 47
    

    In C++ it's probably easier to do without complaints from the compiler (but still not a good idea):

    char* ptr = 0;
    int* pPtr = reinterpret_cast<int*>(&ptr);
    *pPtr = 47;
    *ptr = 4; // POKE 47, 4
    cout << (int)*ptr; // PEEK 47
    

    Only useful if you're doing something like DOS or embedded C++ where specific addresses might give you access to things. But then you should have headers with predefined pointers and not have to do this.

    (sidenote: what's with the forum doublespacing code blocks?)

  • iw (unregistered)
          For Each cmd In cmds
              Try
                  DbReader2 = cmd.ExecuteReader
              Catch ex As Exception
                  If ex.Message = "Invalid column name 'Result'." Then     >>> (YOUR FOOT) <<<
                      If n = 0 Then
                          n = n + 1
                          GoTo CloseCmd
                      Else
                          Continue For
                      End If
                  End If
              End Try
          Next
    
      CloseCmd:
          ...
    
        ^^^^^^^^^
        SPACE GUN
    
  • Sid2K7 (unregistered)

    First: No validation of the "command" (I guess that is what cmd stands for).

    Second: Not using a qualified exception, but identifying an exception based on its message string (which might be localized).

    Third: Exceptions used for flow control.

    Fourth: if n = 0 then n = 1.

    Fifth: Jumping out of a loop with goto when there is a perfectly legal way of quitting (I have to elaborate: I read that there is an "End For" statement in VB, and I see no ellipse down there, so I guess that the label CloseCmd really is below the loop.)

    Captcha: Tesla (brzzzzzzzzzzzzzt*zap*bang)

  • Tom_fan_DK (unregistered) in reply to Nat5an
    Nat5an:
    Dave C.:
    rStacey:
    No, the = operator is overloaded for comparision and assignment depending on context.
    A huge WTF right there.

    Meh, SQL does the same thing, as do other languages, I'm sure. It's not that big of a WTF. Just because it's not like C or Java doesn't make it completely crazy.

    SQL what????

Leave a comment on “Visual Basic Triple Play”

Log In or post as a guest

Replying to comment #:

« Return to Article