• Tom_fan_DK (unregistered) in reply to RobertB
    RobertB:
    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.
    Here's an example of an assignment and a comparison in a simple SQL query.

    Select PseudoFieldName = 'Some value'
    From TableName
    Where Something = Nothing

    And don't forget stored procedures:

    Declare @x int, @y int
    Select @x = 2, @y = 2
    If @x + @y = 5
       Select RetVal = 'For sufficiently large values of 2'
    Else
       Select RetVal = 'You took the blue pill'
    

    Slow down with alcohool... Connect with Oracle, try your statements e let us know the results, if any... ;-)

  • Joseph Newton (unregistered) in reply to Tom_fan_DK
    Tom_fan_DK:
    RobertB:
    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.
    Here's an example of an assignment and a comparison in a simple SQL query.

    Select PseudoFieldName = 'Some value'
    From TableName
    Where Something = Nothing

    And don't forget stored procedures:

    Declare @x int, @y int
    Select @x = 2, @y = 2
    If @x + @y = 5
       Select RetVal = 'For sufficiently large values of 2'
    Else
       Select RetVal = 'You took the blue pill'
    

    Slow down with alcohool... Connect with Oracle, try your statements e let us know the results, if any... ;-)

    With Oracle!? I'll pass. I gave it a try: 3GB of shitware overhead before i'd even started using it. No clear entry points. Who needs it? MySQL and PostgreSQL both provide excellent database functionality with about 130MB, including PostGIS on PG and a number of experimental DBs I've already loaded on MySQL. I just don't have drive-space to waste on Oracles self-promoting, badly integrated bloatware.

    I can't say I'm terribly fond of the sample code you were responding to, either.

  • Sanitarium (unregistered) in reply to Bob Janova
    Bob Janova:
    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 :)

    It actually does not produce a bool in C/C++ either.

    x = 2 returns 2. ;) And as we all know, anything non-0 is considered true. ;)

  • dyslexia (unregistered) in reply to Jens
    Jens:
    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, the "And" and "Or" operators in VB don't short circuit. In VB.NET, they wanted to add that ability, but didn't want to cause problems with people migrating from VB6, so they left it that way. They did, however, add two new operators: "AndAlso" and "OrElse", which function the way you think "And" and "Or" should.

    Really though, while it may be mildly annoying, it's entirely possible (as was pointed out) to short circuit with the non-short circuiting operators if you split them into multiple statements. It also gives you, as was pointed out, the ability to more fully determine the point of failure when something doesn't work.

  • Pixeled (unregistered) in reply to ContractorInLivingHell

    "WAIT" was not an applesoft basic keyword.

    (see http://www.landsnail.com/a2ref.htm)

    "POKE" was, IIRC it was clearing the keyboard.. -16384 was reading the keyboard.. it was latched, so you had to poke -16368 to clear it..

    though usually with zero..

  • Curious (unregistered) in reply to themagni

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

    And how do you do it in C# V1.0?

  • (cs)

    That was pretty cool. I need the same weed to fly that high. Wohaaaw.. That's reaaly hard stuff! I've seen similar one long time ago. That was smth like this

    while(transaction.Commit());

  • (cs) in reply to Anon
    Anon:
    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.

    hmmm ... I wasn't aware that lots of people are building houses with shoes these days, because in order for your analogy to be even remotely applicable that would have to be true.

    If you feel that it is as difficult to code in VB as it would be to build a house with a shoe, then, like usual, I can only suggest that you actually try learning VB and actually using it. Because either you don't know it at all, or you are a pretty poor programmer. Take your pick.

  • (cs)
    <script language="javascript">alert("test");</script>
  • (cs) in reply to Marcin
    Marcin:
    Defend this statement. Please show me a valid sql query which has assignment.

    update foo set bar = ? where baz = ?

  • CDS (unregistered) in reply to KattMan
    KattMan:
    Will:
    Question for someone who knows VB:
    If n = 0

    Is this use of the = operator an assignment in VB, as it would be in C? If so, what is the truth value of an assignment in VB?

    In this context the = is a comparison operator. Basically the first = you find is a assignment all others are comparisons, but this happens only within their own context.

    If x = y and a = b

    The context for each is separate so they are both comparison operators, the IF precedes the first operation.

    It is overloaded as a comparison and an assignment and can lead to some really strange code. i.e.

    dim x as boolean = false dim y as int = 1 dim z as int = 2

    x = y = z x = (y = z)

    Just try to grok that and tell me what the value of x is in each case.

  • SQB (unregistered) in reply to Joseph Newton
    Joseph Newton:
    Tom_fan_DK:
    RobertB:
    <SNIP>

    Here's an example of an assignment and a comparison in a simple SQL query.

    Select PseudoFieldName = 'Some value'
    From TableName
    Where Something = Nothing

    And don't forget stored procedures:

    Declare @x int, @y int
    Select @x = 2, @y = 2
    If @x + @y = 5
       Select RetVal = 'For sufficiently large values of 2'
    Else
       Select RetVal = 'You took the blue pill'
    

    Slow down with alcohool... Connect with Oracle, try your statements e let us know the results, if any... ;-)

    With Oracle!? I'll pass. I gave it a try: 3GB of shitware overhead before i'd even started using it. No clear entry points. Who needs it? MySQL and PostgreSQL both provide excellent database functionality with about 130MB, including PostGIS on PG and a number of experimental DBs I've already loaded on MySQL. I just don't have drive-space to waste on Oracles self-promoting, badly integrated bloatware.

    I can't say I'm terribly fond of the sample code you were responding to, either.

    The point was (guessing) that it's not valid SQL, just valid Transact SQL, which is not the same thing at all -- it's one of the various procedural add ons to SQL, this particular one being MS's which will not work on Oracle.

  • SQB (unregistered) in reply to Jeff S
    Jeff S:
    It's been a while, but I think Pascal does it best:

    a = b means "is a equal to b?" a := b means "assign to a the value of b"

    This keeps = meaning what we always learned it to be, and simply introduces a new syntax for assignment. That's kind of the opposite of how C,C#,Java,etc do it, yet to me it makes much more sense.

    I'd personally prefer a language that uses := for assignment and == for equality, leaving no room for mistakes.

  • jerry (unregistered) in reply to dave

    If x = y then exit for end if

  • zzo38 (unregistered)

    What I notice is wrong:

    • If n=0 then n=n+1 is wrong, if you know n=0 you should n=1 instead (what is the n variable used for anyways?)
    • Shouldn't there be a error code constant for invalid column names? Or maybe not, I don't know much about it (the program and VB.NET) so I don't know. Maybe you need to check the message for which column, but I'm not sure.
    • Other errors other than invalid column names are not caught. Probably this is deliberate, but still you should test it first, maybe they did but I think probably they didn't
    • DbReader2 variable does not appear to be used (I know in VB you can type cmd.ExecuteReader without assigning the return value and it will still work), and if it is, it is set to the last value of cmd.ExecuteReader either the last cmd in cmds or the one with the invalid column name. (The only other reason I can think of is to check if a type cast is possible, but that doesn't make much sense in this context)
    • Is it possible to Exit For from a For Each command? If so, you don't need the GoTo CloseCmd in there
    • Does Continue For just go to the next one? (I think so but I'm not sure because I don't use VB.NET) If so you don't need that in there either!
    • Mostly the wrong things is it just has some reduntent stuff.
  • (cs) in reply to chrismcb
    chrismcb:
    And how is C "assembler" like?

    I'd apologize for bringing up graveyard posts, except that this section of the site doesn't appear to have any access method which is last-post sorted.

    C is 'assembler'-like, in that it is pretty close to 1-1 with PDP 7 assembly, except it has subroutines, and some control structures like 'for', 'while', and 'switch'.

    Since pretty much nobody has a PDP anymore, let alone a 7, this is not very relevant. It certainly doesn't look like any actual assembly language I've seen.

  • Halo (unregistered) in reply to RobertB
    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...)

    You can have control arrays in .NET, they just don't have designer support. But frankly there really is no reason for control arrays as they really only existed in VB5/6 to workaround other limitations, such as the hard 255 control name limit and the inability (or extreme obnoxiousness, in VB6) of loading controls dynamically. In VB.NET there is absolutely nothing that the designer can do that you can't do yourself. Loading a control is painfully simple: Dim tb As New TextBox() : Me.Controls.Add(tb). Wiring dynamic controls to events is similarly simple as events are just based on delegates, so AddHandler and RemoveHandler with AddressOf can subscribe and unsubscribe at will. So, if you want control arrays, just declare an array in code, populate it and add those controls dynamically.

    As for Sub Main, that still exists but it is hidden in Windows Forms projects by default as VB.NET adds a framework on top of such projects to assist with common tasks such as setting up visual styles, handling authentication, supporting splash screens and handling single instance application (that can pass parameters from invoked instances back to the single instance). You are free to turn this off in Project Properties by unchecking the "Enable Application Framework" checkbox at which point Sub Main becomes available as a Startup Object. Then you just need a Main method in a Module (or a class, but the method has to be explicitly marked as Shared.) Note that in VB.NET the Main method doesn't just have to be Sub Main(), it could be Function Main(ByVal args() As String) As Integer.

    It's easy to disparage something when you don't understand it, but that ignorance is your problem, not that of the language. Heck, and I don't even program in VB.NET.

Leave a comment on “Visual Basic Triple Play”

Log In or post as a guest

Replying to comment #:

« Return to Article