Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. VB 6

VB 6

Scheduled Pinned Locked Moved The Weird and The Wonderful
dotnetquestionloungelearning
36 Posts 22 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Lutoslaw

    Just for your pleasure, I have opened a random VB 6 program from my archive to post some horror. This is from a program which purpose was to teach user doing simple math tasks, that is multipying, dividing, adding and subtracting. Well it worked, but I still don't know a multiplication table by heart. I suppose Command1 was a "Start" button. Of course, the same code was copied to a "Next task" button.

    Private Sub Command1_Click()
    x = InputBox("Enter a name or a nick:", "Name?!", nz)
    If x = "" Then Exit Sub
    nz = x
    kon = False
    Command3.Enabled = True
    Command4.Enabled = True
    dzial.Interval = Text4 * 1000 // adjustable time restrictions, cool
    odp.Interval = Text5 * 1000
    Label1 = ""
    Label8 = ""
    Label1.Visible = True
    il = 0
    oc = 6
    ' Combo2.AddItem "0 - First component (denary)"
    ' Combo2.AddItem "1 - Both components (denary)"
    ' Combo2.AddItem "2 - First component (hundredth)"
    ' Combo2.AddItem "3 - Both components (hundredth)" <== whatever that means... ;)
    If Check1 = 1 Then
    ul = Combo2.ListIndex
    Else
    ul = 124
    End If
    1:
    Randomize
    d1 = Int((Text2 + 1) * Rnd)
    Randomize // randomize every time -- that time I though that it would give "more random" numbers...
    d2 = Int((Text3 + 1) * Rnd)
    Randomize
    If Check2 = 1 Then
    rd = Int((4) * Rnd + 1)
    Else
    rd = Int((2) * Rnd + 1)
    End If
    If d1 = 0 Or d2 = 0 Or rd < 1 Or d1 = d2 Or d1 = 1 Or d2 = 1 Or rd > 4 Then GoTo 1
    Randomize
    If ul = 0 Or ul = 1 Then
    a = Int((9 + 1) * Rnd)
    a = Left(a, 1)
    c = Str(d1)
    c = c & "." & Str(a) //Whoa...
    d1 = CDbl(c)
    End If
    If ul = 1 Then
    a = Int((9 + 1) * Rnd)
    a = Left(a, 1)
    c = Str(d2)
    c = c & "." & Str(a)
    d2 = CDbl(c)
    End If
    If ul = 2 Or ul = 3 Then
    a = Int((99 + 1) * Rnd)
    a = Left(a, 2)
    c = Str(d1)
    c = c & "." & Str(a)
    d1 = CDbl(c)
    End If
    If ul = 3 Then
    a = Int((99 + 1) * Rnd)
    a = Left(a, 2)
    c = Str(d2)
    c = c & "." & Str(a)
    d2 = CDbl(c)
    End If
    If rd = 1 Then
    w = d1 * d2
    Label1 = d1 & " times " & d2 & " =?"
    ElseIf rd = 2 Then
    w = d2
    Label1 = d1 * d2 & " divided by " & d1 & " =?"
    ElseIf rd = 3 Then
    w = d1 + d2
    Label1 = d1 & " add " & d2 & " =?"
    ElseIf rd = 4 Then
    w = d1 - d2
    Label1 = d1 & " minus " & d2 & " =?"
    End If
    dzial.Enabled = True
    odp.Enabled = True
    Command4.Enabled = False
    Frame1.Enabled = False
    Text1.SetFocus
    Text1.SelStart = 0
    Text1.SelLength = Len(Text1)
    Command2.Enabled = False
    End Sub

    A correct answer was stored in a global vari

    M Offline
    M Offline
    M i s t e r L i s t e r
    wrote on last edited by
    #14

    VB should just be put out of it's misery !

    1 Reply Last reply
    0
    • R Rob Grainger

      Jacek Gajek wrote:

      1. Option Explicit Off

      Yes this is horrible, almost as bad as JavaScript doing exactly the same, but with (until ECMAScript5) no equivalent of Option Explicit On.

      Jacek Gajek wrote:

      2. On Error Goto Label37

      Quite horrible, but to blame VB for a fault in BASIC since the year dot is a bit unfair. 3. With/End With - OK, this is truly a mistake. 4. I don't like globals either, but most languages, particularly of that era, support them. 5. someInteger = CInt(int1/int2) (divide operator on two ints gives... a double). Actually - thats pretty correct. Last time I checked 1/2 in mathematics was 0.5, not 0 or 1. Ideally, a language can distinguish integer division and floating-point division, maybe with different operators, but this doesn't seem too horrible to me. 6. Yes, a terrible decision, and Option Base 0 just made things worse, as code in different modules can have different bases. I don't mind base 0 or 1, consistency is really important. 7. Not sure what you're referring to here, but if you mean null-propagation where nulls occur in boolean expressions (where null is an allowable result), that's the only option. Check the literature on Relational DB's (Codd et al.) for the justification. Actually, Codd proposes 4-state logic (Yes,No,Maybe and Inapplicable, Maybe and Applicable). These are not really boolean logic though, but VB, with typed variables (As Boolean) behaves correctly AFAIK. It's not a great language, but most languages have points that are plain bad (JavaScript springs to mind heavily). Programmer's should be able to avoid features that cause problems - that's what they're paid for. I've seen plenty of bad Javascript too - for basically the same reasons as VB. Maybe we should just ban high-level languages ;-)

      S Offline
      S Offline
      sergiogarcianinja
      wrote on last edited by
      #15

      Rob, You should consider more two VB features: 8. Automatic type conversions like:

      Dim a As Integer = "1"

      9. Not assigment or type checking at compile type:

      Dim c As Object

      Select Case c
      Case 1
      ' do something 1
      Case "horror"
      ' its really bad
      Case Color.Green
      ' its even worst
      End Select

      This code generates a warning for use of c before its assignment, a incredible error, because it will never run. And it happens in modern VB.Net versions. --- We could assume that you like VB and we could accept it. Every programmer have your "perfect" language and consider it best as no one other. I know VB since version 5.0 and even today I use this language in a lot of legacy projects, but never in a new project. I know a lot of other languages (C, C++, C#, Python, Perl, PHP, Javascript, Bash, Java, Delphi) and each time I will start a new project, I never consider VB, because its problems. Fact is Basic and VB are extremely easy to start programming but they "easiness" are really complicated for the real programmer. A real programmer should be able to run a program and it need to be deterministic. Same input, same output. Some time a go, a friend mine was asking why a simple sum operation became wrong. She was using ASP 3.0, which uses VBScript, and 1 + 1 are equal to 11. As I saw that, I told her, perfect normal, what was you expecting? I told her simple to type her variables Dim a As Integer = 1, problem solved. As me, and probably you, use VB along time both of us know that its evolution is really impressive. In version 5 and 6 its is a really poor in resource for type checking and compile time checking. Today it is more impressive, today 1 + 1 is really 2. The easiness of VB 1, 2, 3, 4, 5 and we can consider version 6 to create and deploy windows applications are amazing, because your RAD and "good" (for the time) IDE. Even with creation of Delphi, VB had evangelized his people. But again, today, we can consider VB a good choice in real big and important projects. Project which requires use of good patterns, use o interfaces, a lot of modules, etc. VB can't handle this. But again, it's my opinion. I consider VB a easy language not a good one.

      R 1 Reply Last reply
      0
      • R Rob Grainger

        Jacek Gajek wrote:

        1. Option Explicit Off

        Yes this is horrible, almost as bad as JavaScript doing exactly the same, but with (until ECMAScript5) no equivalent of Option Explicit On.

        Jacek Gajek wrote:

        2. On Error Goto Label37

        Quite horrible, but to blame VB for a fault in BASIC since the year dot is a bit unfair. 3. With/End With - OK, this is truly a mistake. 4. I don't like globals either, but most languages, particularly of that era, support them. 5. someInteger = CInt(int1/int2) (divide operator on two ints gives... a double). Actually - thats pretty correct. Last time I checked 1/2 in mathematics was 0.5, not 0 or 1. Ideally, a language can distinguish integer division and floating-point division, maybe with different operators, but this doesn't seem too horrible to me. 6. Yes, a terrible decision, and Option Base 0 just made things worse, as code in different modules can have different bases. I don't mind base 0 or 1, consistency is really important. 7. Not sure what you're referring to here, but if you mean null-propagation where nulls occur in boolean expressions (where null is an allowable result), that's the only option. Check the literature on Relational DB's (Codd et al.) for the justification. Actually, Codd proposes 4-state logic (Yes,No,Maybe and Inapplicable, Maybe and Applicable). These are not really boolean logic though, but VB, with typed variables (As Boolean) behaves correctly AFAIK. It's not a great language, but most languages have points that are plain bad (JavaScript springs to mind heavily). Programmer's should be able to avoid features that cause problems - that's what they're paid for. I've seen plenty of bad Javascript too - for basically the same reasons as VB. Maybe we should just ban high-level languages ;-)

        E Offline
        E Offline
        edmurphy99
        wrote on last edited by
        #16

        on error goto Shoot_Foot

        1 Reply Last reply
        0
        • L Lutoslaw

          Just for your pleasure, I have opened a random VB 6 program from my archive to post some horror. This is from a program which purpose was to teach user doing simple math tasks, that is multipying, dividing, adding and subtracting. Well it worked, but I still don't know a multiplication table by heart. I suppose Command1 was a "Start" button. Of course, the same code was copied to a "Next task" button.

          Private Sub Command1_Click()
          x = InputBox("Enter a name or a nick:", "Name?!", nz)
          If x = "" Then Exit Sub
          nz = x
          kon = False
          Command3.Enabled = True
          Command4.Enabled = True
          dzial.Interval = Text4 * 1000 // adjustable time restrictions, cool
          odp.Interval = Text5 * 1000
          Label1 = ""
          Label8 = ""
          Label1.Visible = True
          il = 0
          oc = 6
          ' Combo2.AddItem "0 - First component (denary)"
          ' Combo2.AddItem "1 - Both components (denary)"
          ' Combo2.AddItem "2 - First component (hundredth)"
          ' Combo2.AddItem "3 - Both components (hundredth)" <== whatever that means... ;)
          If Check1 = 1 Then
          ul = Combo2.ListIndex
          Else
          ul = 124
          End If
          1:
          Randomize
          d1 = Int((Text2 + 1) * Rnd)
          Randomize // randomize every time -- that time I though that it would give "more random" numbers...
          d2 = Int((Text3 + 1) * Rnd)
          Randomize
          If Check2 = 1 Then
          rd = Int((4) * Rnd + 1)
          Else
          rd = Int((2) * Rnd + 1)
          End If
          If d1 = 0 Or d2 = 0 Or rd < 1 Or d1 = d2 Or d1 = 1 Or d2 = 1 Or rd > 4 Then GoTo 1
          Randomize
          If ul = 0 Or ul = 1 Then
          a = Int((9 + 1) * Rnd)
          a = Left(a, 1)
          c = Str(d1)
          c = c & "." & Str(a) //Whoa...
          d1 = CDbl(c)
          End If
          If ul = 1 Then
          a = Int((9 + 1) * Rnd)
          a = Left(a, 1)
          c = Str(d2)
          c = c & "." & Str(a)
          d2 = CDbl(c)
          End If
          If ul = 2 Or ul = 3 Then
          a = Int((99 + 1) * Rnd)
          a = Left(a, 2)
          c = Str(d1)
          c = c & "." & Str(a)
          d1 = CDbl(c)
          End If
          If ul = 3 Then
          a = Int((99 + 1) * Rnd)
          a = Left(a, 2)
          c = Str(d2)
          c = c & "." & Str(a)
          d2 = CDbl(c)
          End If
          If rd = 1 Then
          w = d1 * d2
          Label1 = d1 & " times " & d2 & " =?"
          ElseIf rd = 2 Then
          w = d2
          Label1 = d1 * d2 & " divided by " & d1 & " =?"
          ElseIf rd = 3 Then
          w = d1 + d2
          Label1 = d1 & " add " & d2 & " =?"
          ElseIf rd = 4 Then
          w = d1 - d2
          Label1 = d1 & " minus " & d2 & " =?"
          End If
          dzial.Enabled = True
          odp.Enabled = True
          Command4.Enabled = False
          Frame1.Enabled = False
          Text1.SetFocus
          Text1.SelStart = 0
          Text1.SelLength = Len(Text1)
          Command2.Enabled = False
          End Sub

          A correct answer was stored in a global vari

          B Offline
          B Offline
          bwallan
          wrote on last edited by
          #17

          Beautiful! Just absolutely beautiful... bwa

          1 Reply Last reply
          0
          • R Rob Grainger

            Jacek Gajek wrote:

            1. Option Explicit Off

            Yes this is horrible, almost as bad as JavaScript doing exactly the same, but with (until ECMAScript5) no equivalent of Option Explicit On.

            Jacek Gajek wrote:

            2. On Error Goto Label37

            Quite horrible, but to blame VB for a fault in BASIC since the year dot is a bit unfair. 3. With/End With - OK, this is truly a mistake. 4. I don't like globals either, but most languages, particularly of that era, support them. 5. someInteger = CInt(int1/int2) (divide operator on two ints gives... a double). Actually - thats pretty correct. Last time I checked 1/2 in mathematics was 0.5, not 0 or 1. Ideally, a language can distinguish integer division and floating-point division, maybe with different operators, but this doesn't seem too horrible to me. 6. Yes, a terrible decision, and Option Base 0 just made things worse, as code in different modules can have different bases. I don't mind base 0 or 1, consistency is really important. 7. Not sure what you're referring to here, but if you mean null-propagation where nulls occur in boolean expressions (where null is an allowable result), that's the only option. Check the literature on Relational DB's (Codd et al.) for the justification. Actually, Codd proposes 4-state logic (Yes,No,Maybe and Inapplicable, Maybe and Applicable). These are not really boolean logic though, but VB, with typed variables (As Boolean) behaves correctly AFAIK. It's not a great language, but most languages have points that are plain bad (JavaScript springs to mind heavily). Programmer's should be able to avoid features that cause problems - that's what they're paid for. I've seen plenty of bad Javascript too - for basically the same reasons as VB. Maybe we should just ban high-level languages ;-)

            OriginalGriffO Offline
            OriginalGriffO Offline
            OriginalGriff
            wrote on last edited by
            #18

            Any language which contains code to deliberately hide errors and pretend they didn't happen should not be released into the wild. Particularly if innocent and impressionable children (read: students) can be contaminated by it. "On Error Resume Next" X|

            Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

            T 1 Reply Last reply
            0
            • L Lutoslaw

              Just for your pleasure, I have opened a random VB 6 program from my archive to post some horror. This is from a program which purpose was to teach user doing simple math tasks, that is multipying, dividing, adding and subtracting. Well it worked, but I still don't know a multiplication table by heart. I suppose Command1 was a "Start" button. Of course, the same code was copied to a "Next task" button.

              Private Sub Command1_Click()
              x = InputBox("Enter a name or a nick:", "Name?!", nz)
              If x = "" Then Exit Sub
              nz = x
              kon = False
              Command3.Enabled = True
              Command4.Enabled = True
              dzial.Interval = Text4 * 1000 // adjustable time restrictions, cool
              odp.Interval = Text5 * 1000
              Label1 = ""
              Label8 = ""
              Label1.Visible = True
              il = 0
              oc = 6
              ' Combo2.AddItem "0 - First component (denary)"
              ' Combo2.AddItem "1 - Both components (denary)"
              ' Combo2.AddItem "2 - First component (hundredth)"
              ' Combo2.AddItem "3 - Both components (hundredth)" <== whatever that means... ;)
              If Check1 = 1 Then
              ul = Combo2.ListIndex
              Else
              ul = 124
              End If
              1:
              Randomize
              d1 = Int((Text2 + 1) * Rnd)
              Randomize // randomize every time -- that time I though that it would give "more random" numbers...
              d2 = Int((Text3 + 1) * Rnd)
              Randomize
              If Check2 = 1 Then
              rd = Int((4) * Rnd + 1)
              Else
              rd = Int((2) * Rnd + 1)
              End If
              If d1 = 0 Or d2 = 0 Or rd < 1 Or d1 = d2 Or d1 = 1 Or d2 = 1 Or rd > 4 Then GoTo 1
              Randomize
              If ul = 0 Or ul = 1 Then
              a = Int((9 + 1) * Rnd)
              a = Left(a, 1)
              c = Str(d1)
              c = c & "." & Str(a) //Whoa...
              d1 = CDbl(c)
              End If
              If ul = 1 Then
              a = Int((9 + 1) * Rnd)
              a = Left(a, 1)
              c = Str(d2)
              c = c & "." & Str(a)
              d2 = CDbl(c)
              End If
              If ul = 2 Or ul = 3 Then
              a = Int((99 + 1) * Rnd)
              a = Left(a, 2)
              c = Str(d1)
              c = c & "." & Str(a)
              d1 = CDbl(c)
              End If
              If ul = 3 Then
              a = Int((99 + 1) * Rnd)
              a = Left(a, 2)
              c = Str(d2)
              c = c & "." & Str(a)
              d2 = CDbl(c)
              End If
              If rd = 1 Then
              w = d1 * d2
              Label1 = d1 & " times " & d2 & " =?"
              ElseIf rd = 2 Then
              w = d2
              Label1 = d1 * d2 & " divided by " & d1 & " =?"
              ElseIf rd = 3 Then
              w = d1 + d2
              Label1 = d1 & " add " & d2 & " =?"
              ElseIf rd = 4 Then
              w = d1 - d2
              Label1 = d1 & " minus " & d2 & " =?"
              End If
              dzial.Enabled = True
              odp.Enabled = True
              Command4.Enabled = False
              Frame1.Enabled = False
              Text1.SetFocus
              Text1.SelStart = 0
              Text1.SelLength = Len(Text1)
              Command2.Enabled = False
              End Sub

              A correct answer was stored in a global vari

              J Offline
              J Offline
              JasonPSage
              wrote on last edited by
              #19

              This is a response to all the posts in this topic before mine... you might know what I'm referring to if you read this thread up until this post... I've written miles of VB5,6 code and folks can knock it all they like but I think it was one of the best products Microsoft has made alongside forcefeedback joysticks, access 2003, excel 2003 and DirectX in my opinion. It is one of first totally RAD programming languages in my opinion: True Binary, tons of widget addons, ADO, ODBC, RDO .. tons of ways to communicate with databases and whip up applications quickly with integrated set up and deployment tools - all wrapped into one seamless package if you wen corporate - not to mention it supports various client/server (two tier/three tier systems easily. On error resume next? You can test the error result after that command - SO? what's the problem? How is that different then try catch? You can do the same thing... and frankly - there is a time and place for any code construct - even GOTO. I love when folks get indignant about GOTO and other coding philosophy. I truly believe users just want software that works - less flash and more "DO" ... and * If you write beautiful code that is easy to read and performs great: AWESOME! * If you write ugly code that works.. well.. I wouldn't recommend it but before I chastise ya: How much time did you have to get it done? Boss breathing down your neck? Simply didn't care? All valid reasons to write crap and "Git-R-Dun" in my opinion... Example: Coder: I need two days to do this right! Boss: I need it NOW.. an Hour! Worker: Sure thing boss! VB6 is pretty darn sweet and I say if they had a vb7 by the same development team with better multi-tasking - I would chose it over .Net any day! --Jason

              Know way too many languages... master of none!

              L 1 Reply Last reply
              0
              • L Lutoslaw

                1. Option Explicit Off 2. On Error Goto Label37 3.

                With Object.Its.So.Nested

                (...)

                abc = .Some.Property // WTF?

                (...)

                End With

                4. Global myVar As String = "magic" 5. someInteger = CInt(int1/int2) (divide operator on two ints gives... a double). 6. Non-zero based arrays -- a fantastic source of confusion 7. Propagating null value in nullable boolean logic -- three-state logic? uhm? I won't be suprised if the next VB version would have a fuzzy logic implemented. Not a problem with a language? I don't think so...

                Greetings - Jacek

                L Offline
                L Offline
                leonej_dt
                wrote on last edited by
                #20

                3. VB has an integer division operator: 9 \ 4 returns 2, not 2.25. 4. Propagating the null value in expressions is correct. Technically, there is a difference between

                Dim a As Variant
                a = long_expression_possibly_returning_null
                If a = True Then
                some_code
                Else
                more_code
                End If

                and

                Dim a As Variant
                a = long_expression_possibly_returning_null
                If a = True Then
                some_code
                ElseIf a = False Then
                more_code
                End If

                And the difference consists on how the program handles the case in which a Is Null. Still, I agree that VB is a very horrible language: 1. Default ByRef parameters? What were VB designers smoking? 2. No support for object-oriented programming would have been better than the weak support VB offers. 3. Weak support for value data types, which does not include operator overloading. (Java is guilty of this as well.) 4. Fairly common data structures such as collections and dictionaries are a mess. 5. Even more common Generic data structures such as stacks, queues and trees are simply not supported. And there is no clean, efficient way to implement them. 6. The only way to take full advantage of the power of the Win32 API is use gross hacks à la Bruce McKinney's Hardcore Visual Basic, aka, C (not even C++!) programming in VB.

                If you can play The Dance of Eternity (Dream Theater), then we shall make a band.

                1 Reply Last reply
                0
                • L Lutoslaw

                  Just for your pleasure, I have opened a random VB 6 program from my archive to post some horror. This is from a program which purpose was to teach user doing simple math tasks, that is multipying, dividing, adding and subtracting. Well it worked, but I still don't know a multiplication table by heart. I suppose Command1 was a "Start" button. Of course, the same code was copied to a "Next task" button.

                  Private Sub Command1_Click()
                  x = InputBox("Enter a name or a nick:", "Name?!", nz)
                  If x = "" Then Exit Sub
                  nz = x
                  kon = False
                  Command3.Enabled = True
                  Command4.Enabled = True
                  dzial.Interval = Text4 * 1000 // adjustable time restrictions, cool
                  odp.Interval = Text5 * 1000
                  Label1 = ""
                  Label8 = ""
                  Label1.Visible = True
                  il = 0
                  oc = 6
                  ' Combo2.AddItem "0 - First component (denary)"
                  ' Combo2.AddItem "1 - Both components (denary)"
                  ' Combo2.AddItem "2 - First component (hundredth)"
                  ' Combo2.AddItem "3 - Both components (hundredth)" <== whatever that means... ;)
                  If Check1 = 1 Then
                  ul = Combo2.ListIndex
                  Else
                  ul = 124
                  End If
                  1:
                  Randomize
                  d1 = Int((Text2 + 1) * Rnd)
                  Randomize // randomize every time -- that time I though that it would give "more random" numbers...
                  d2 = Int((Text3 + 1) * Rnd)
                  Randomize
                  If Check2 = 1 Then
                  rd = Int((4) * Rnd + 1)
                  Else
                  rd = Int((2) * Rnd + 1)
                  End If
                  If d1 = 0 Or d2 = 0 Or rd < 1 Or d1 = d2 Or d1 = 1 Or d2 = 1 Or rd > 4 Then GoTo 1
                  Randomize
                  If ul = 0 Or ul = 1 Then
                  a = Int((9 + 1) * Rnd)
                  a = Left(a, 1)
                  c = Str(d1)
                  c = c & "." & Str(a) //Whoa...
                  d1 = CDbl(c)
                  End If
                  If ul = 1 Then
                  a = Int((9 + 1) * Rnd)
                  a = Left(a, 1)
                  c = Str(d2)
                  c = c & "." & Str(a)
                  d2 = CDbl(c)
                  End If
                  If ul = 2 Or ul = 3 Then
                  a = Int((99 + 1) * Rnd)
                  a = Left(a, 2)
                  c = Str(d1)
                  c = c & "." & Str(a)
                  d1 = CDbl(c)
                  End If
                  If ul = 3 Then
                  a = Int((99 + 1) * Rnd)
                  a = Left(a, 2)
                  c = Str(d2)
                  c = c & "." & Str(a)
                  d2 = CDbl(c)
                  End If
                  If rd = 1 Then
                  w = d1 * d2
                  Label1 = d1 & " times " & d2 & " =?"
                  ElseIf rd = 2 Then
                  w = d2
                  Label1 = d1 * d2 & " divided by " & d1 & " =?"
                  ElseIf rd = 3 Then
                  w = d1 + d2
                  Label1 = d1 & " add " & d2 & " =?"
                  ElseIf rd = 4 Then
                  w = d1 - d2
                  Label1 = d1 & " minus " & d2 & " =?"
                  End If
                  dzial.Enabled = True
                  odp.Enabled = True
                  Command4.Enabled = False
                  Frame1.Enabled = False
                  Text1.SetFocus
                  Text1.SelStart = 0
                  Text1.SelLength = Len(Text1)
                  Command2.Enabled = False
                  End Sub

                  A correct answer was stored in a global vari

                  M Offline
                  M Offline
                  Matt McGuire
                  wrote on last edited by
                  #21

                  true, that does hurt. but you should have seen some c code I had to take over when I first arived at the company I now work for. something along the lines--- void _add{ int a,b,c,d,e,f,g,h,i,j,k,l,m,n; int aa,bb,cc,iiii,iii,ii,i; if {z==0}n=3; /*declared in globals*/ b=1 } all of the code was like this, with vars never even refrenced in the code, except for one var that is assigned a variable, but never actually used. the names of the functions had no correlation to the body of code inside of them! yes, most of it was scrubbed, as no one could follow the majority of the logic.

                  L 1 Reply Last reply
                  0
                  • C Chris Meech

                    At least in English, the poems ryhme. :)

                    Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]

                    J Offline
                    J Offline
                    jmoralesv
                    wrote on last edited by
                    #22

                    As in Spanish also ;) I love my language :-D

                    1 Reply Last reply
                    0
                    • M Matt McGuire

                      true, that does hurt. but you should have seen some c code I had to take over when I first arived at the company I now work for. something along the lines--- void _add{ int a,b,c,d,e,f,g,h,i,j,k,l,m,n; int aa,bb,cc,iiii,iii,ii,i; if {z==0}n=3; /*declared in globals*/ b=1 } all of the code was like this, with vars never even refrenced in the code, except for one var that is assigned a variable, but never actually used. the names of the functions had no correlation to the body of code inside of them! yes, most of it was scrubbed, as no one could follow the majority of the logic.

                      L Offline
                      L Offline
                      Lutoslaw
                      wrote on last edited by
                      #23

                      Maybe a programmer who wrote this was using a lot an early version of BASIC, where variables had to match a pattern ([A-Z][A-Z]) (identifiers not longer than two characters, not case sensitive, a-z letters can be accesed via an array A, e.g. A[3]=C as well as other "advantages"). BTW in your code i is declared twice.

                      Greetings - Jacek

                      1 Reply Last reply
                      0
                      • S sergiogarcianinja

                        Rob, You should consider more two VB features: 8. Automatic type conversions like:

                        Dim a As Integer = "1"

                        9. Not assigment or type checking at compile type:

                        Dim c As Object

                        Select Case c
                        Case 1
                        ' do something 1
                        Case "horror"
                        ' its really bad
                        Case Color.Green
                        ' its even worst
                        End Select

                        This code generates a warning for use of c before its assignment, a incredible error, because it will never run. And it happens in modern VB.Net versions. --- We could assume that you like VB and we could accept it. Every programmer have your "perfect" language and consider it best as no one other. I know VB since version 5.0 and even today I use this language in a lot of legacy projects, but never in a new project. I know a lot of other languages (C, C++, C#, Python, Perl, PHP, Javascript, Bash, Java, Delphi) and each time I will start a new project, I never consider VB, because its problems. Fact is Basic and VB are extremely easy to start programming but they "easiness" are really complicated for the real programmer. A real programmer should be able to run a program and it need to be deterministic. Same input, same output. Some time a go, a friend mine was asking why a simple sum operation became wrong. She was using ASP 3.0, which uses VBScript, and 1 + 1 are equal to 11. As I saw that, I told her, perfect normal, what was you expecting? I told her simple to type her variables Dim a As Integer = 1, problem solved. As me, and probably you, use VB along time both of us know that its evolution is really impressive. In version 5 and 6 its is a really poor in resource for type checking and compile time checking. Today it is more impressive, today 1 + 1 is really 2. The easiness of VB 1, 2, 3, 4, 5 and we can consider version 6 to create and deploy windows applications are amazing, because your RAD and "good" (for the time) IDE. Even with creation of Delphi, VB had evangelized his people. But again, today, we can consider VB a good choice in real big and important projects. Project which requires use of good patterns, use o interfaces, a lot of modules, etc. VB can't handle this. But again, it's my opinion. I consider VB a easy language not a good one.

                        R Offline
                        R Offline
                        Rob Grainger
                        wrote on last edited by
                        #24

                        Sergio, Fair points - actually, I have to use VB at work but would much prefer use C#, or even better a true OO language like Smalltalk, but there seems little call for that in this neck of the woods. I've used VB in one form or another intermittently since VB 1.0 - at that stage, even though primitive by todays standards, the IDE was mind-blowing, the first time I was able to draw a GUI, and add event-handling code so easily. I agree re. auto type conversion - in a typed language that's horrible, although many modern languages seem to do this sort of stuff (particularly in the Scripting arena, and I'd guess VB's kind of midway between there and a typical statically-typed language). Like you I have experience with a wide range of languages (slightly different selection, but generally similar). Many languages have these kinds of faults - JavaScript has a whole set of them, but it seems to get nothing like the volume of criticism directed at VB. C has a whole different set, that tend to lead to more catastrophic run-time errors. The basic fact remains that whatever language you use, you need to learn its strengths and, particularly, its weaknesses, so you can exploit one and avoid the other. Regards, Rob

                        1 Reply Last reply
                        0
                        • J JasonPSage

                          This is a response to all the posts in this topic before mine... you might know what I'm referring to if you read this thread up until this post... I've written miles of VB5,6 code and folks can knock it all they like but I think it was one of the best products Microsoft has made alongside forcefeedback joysticks, access 2003, excel 2003 and DirectX in my opinion. It is one of first totally RAD programming languages in my opinion: True Binary, tons of widget addons, ADO, ODBC, RDO .. tons of ways to communicate with databases and whip up applications quickly with integrated set up and deployment tools - all wrapped into one seamless package if you wen corporate - not to mention it supports various client/server (two tier/three tier systems easily. On error resume next? You can test the error result after that command - SO? what's the problem? How is that different then try catch? You can do the same thing... and frankly - there is a time and place for any code construct - even GOTO. I love when folks get indignant about GOTO and other coding philosophy. I truly believe users just want software that works - less flash and more "DO" ... and * If you write beautiful code that is easy to read and performs great: AWESOME! * If you write ugly code that works.. well.. I wouldn't recommend it but before I chastise ya: How much time did you have to get it done? Boss breathing down your neck? Simply didn't care? All valid reasons to write crap and "Git-R-Dun" in my opinion... Example: Coder: I need two days to do this right! Boss: I need it NOW.. an Hour! Worker: Sure thing boss! VB6 is pretty darn sweet and I say if they had a vb7 by the same development team with better multi-tasking - I would chose it over .Net any day! --Jason

                          Know way too many languages... master of none!

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #25

                          I concur. We have a time & attendance system that was originally developed in VB6 that serves thousands of clients on a daily basis. (Some of these clients have > 10,000 employees). The current enterprise-level solution is now a mix of the VB6 stuff and .Net. Since 2005 the management kept saying "in 6 months we'll get rid of VB6 code". Now, years later, the ratio of the VB6 code to the .Net section is about the same. Why? The stuff just plain works, that's why. Agreed, .Net is far more refined a product than VB6 is - it had better be, it's 12 years newer (in its latest version that is). However even now the VB6 code continues to ensure that paychecks are accurately produced and the system continues to hum along. VB6 may wind up being the next COBOL. It will eventually fall off the radar but in the background will continue to get results for years to come. One developer said that he'd never take another job where he would have to deal with VB6. That's all right son, just send that work my way. I won't turn my nose up - they pay me big bucks to fix systems that the kids don't want to bother with anymore. :-) I love .Net (absolutely crazy about C#) but, at the same time I find it a breath of fresh air sometimes to go back to VB6. Besides being a competent development environment it is just plain FUN. -Max :-)

                          1 Reply Last reply
                          0
                          • L Lutoslaw

                            Just for your pleasure, I have opened a random VB 6 program from my archive to post some horror. This is from a program which purpose was to teach user doing simple math tasks, that is multipying, dividing, adding and subtracting. Well it worked, but I still don't know a multiplication table by heart. I suppose Command1 was a "Start" button. Of course, the same code was copied to a "Next task" button.

                            Private Sub Command1_Click()
                            x = InputBox("Enter a name or a nick:", "Name?!", nz)
                            If x = "" Then Exit Sub
                            nz = x
                            kon = False
                            Command3.Enabled = True
                            Command4.Enabled = True
                            dzial.Interval = Text4 * 1000 // adjustable time restrictions, cool
                            odp.Interval = Text5 * 1000
                            Label1 = ""
                            Label8 = ""
                            Label1.Visible = True
                            il = 0
                            oc = 6
                            ' Combo2.AddItem "0 - First component (denary)"
                            ' Combo2.AddItem "1 - Both components (denary)"
                            ' Combo2.AddItem "2 - First component (hundredth)"
                            ' Combo2.AddItem "3 - Both components (hundredth)" <== whatever that means... ;)
                            If Check1 = 1 Then
                            ul = Combo2.ListIndex
                            Else
                            ul = 124
                            End If
                            1:
                            Randomize
                            d1 = Int((Text2 + 1) * Rnd)
                            Randomize // randomize every time -- that time I though that it would give "more random" numbers...
                            d2 = Int((Text3 + 1) * Rnd)
                            Randomize
                            If Check2 = 1 Then
                            rd = Int((4) * Rnd + 1)
                            Else
                            rd = Int((2) * Rnd + 1)
                            End If
                            If d1 = 0 Or d2 = 0 Or rd < 1 Or d1 = d2 Or d1 = 1 Or d2 = 1 Or rd > 4 Then GoTo 1
                            Randomize
                            If ul = 0 Or ul = 1 Then
                            a = Int((9 + 1) * Rnd)
                            a = Left(a, 1)
                            c = Str(d1)
                            c = c & "." & Str(a) //Whoa...
                            d1 = CDbl(c)
                            End If
                            If ul = 1 Then
                            a = Int((9 + 1) * Rnd)
                            a = Left(a, 1)
                            c = Str(d2)
                            c = c & "." & Str(a)
                            d2 = CDbl(c)
                            End If
                            If ul = 2 Or ul = 3 Then
                            a = Int((99 + 1) * Rnd)
                            a = Left(a, 2)
                            c = Str(d1)
                            c = c & "." & Str(a)
                            d1 = CDbl(c)
                            End If
                            If ul = 3 Then
                            a = Int((99 + 1) * Rnd)
                            a = Left(a, 2)
                            c = Str(d2)
                            c = c & "." & Str(a)
                            d2 = CDbl(c)
                            End If
                            If rd = 1 Then
                            w = d1 * d2
                            Label1 = d1 & " times " & d2 & " =?"
                            ElseIf rd = 2 Then
                            w = d2
                            Label1 = d1 * d2 & " divided by " & d1 & " =?"
                            ElseIf rd = 3 Then
                            w = d1 + d2
                            Label1 = d1 & " add " & d2 & " =?"
                            ElseIf rd = 4 Then
                            w = d1 - d2
                            Label1 = d1 & " minus " & d2 & " =?"
                            End If
                            dzial.Enabled = True
                            odp.Enabled = True
                            Command4.Enabled = False
                            Frame1.Enabled = False
                            Text1.SetFocus
                            Text1.SelStart = 0
                            Text1.SelLength = Len(Text1)
                            Command2.Enabled = False
                            End Sub

                            A correct answer was stored in a global vari

                            C Offline
                            C Offline
                            cwp42
                            wrote on last edited by
                            #26

                            It always depends on the coder !!! You can do this horror in every language.

                            cwp42

                            1 Reply Last reply
                            0
                            • OriginalGriffO OriginalGriff

                              Any language which contains code to deliberately hide errors and pretend they didn't happen should not be released into the wild. Particularly if innocent and impressionable children (read: students) can be contaminated by it. "On Error Resume Next" X|

                              Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                              T Offline
                              T Offline
                              Thomas Eyde
                              wrote on last edited by
                              #27

                              Try with an empty catch does just the same. Does this statement apply to all these languages, including C# and Java?

                              OriginalGriffO 1 Reply Last reply
                              0
                              • T Thomas Eyde

                                Try with an empty catch does just the same. Does this statement apply to all these languages, including C# and Java?

                                OriginalGriffO Offline
                                OriginalGriffO Offline
                                OriginalGriff
                                wrote on last edited by
                                #28

                                No, it doesn't! Try with an empty catch would only work the same if you surrounded each and every single line of code with it's own, independent, try...empty catch block. Not even the laziest programmer on the planet would do that... Having said that, it is possible a very thick student might. But he wouldn't get a passing grade for it.

                                Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                T R 2 Replies Last reply
                                0
                                • OriginalGriffO OriginalGriff

                                  No, it doesn't! Try with an empty catch would only work the same if you surrounded each and every single line of code with it's own, independent, try...empty catch block. Not even the laziest programmer on the planet would do that... Having said that, it is possible a very thick student might. But he wouldn't get a passing grade for it.

                                  Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                                  T Offline
                                  T Offline
                                  Thomas Eyde
                                  wrote on last edited by
                                  #29

                                  That's true. My point was that a swallowed exception leaves the program in an invalid state. Even if the magnitude is smaller, no language can protect us from bad practice.

                                  OriginalGriffO 1 Reply Last reply
                                  0
                                  • T Thomas Eyde

                                    That's true. My point was that a swallowed exception leaves the program in an invalid state. Even if the magnitude is smaller, no language can protect us from bad practice.

                                    OriginalGriffO Offline
                                    OriginalGriffO Offline
                                    OriginalGriff
                                    wrote on last edited by
                                    #30

                                    I agree - but a language that has that designed in to make it easy? :wtf:

                                    Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                                    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                    1 Reply Last reply
                                    0
                                    • OriginalGriffO OriginalGriff

                                      No, it doesn't! Try with an empty catch would only work the same if you surrounded each and every single line of code with it's own, independent, try...empty catch block. Not even the laziest programmer on the planet would do that... Having said that, it is possible a very thick student might. But he wouldn't get a passing grade for it.

                                      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                                      R Offline
                                      R Offline
                                      Richard A Dalton
                                      wrote on last edited by
                                      #31

                                      OriginalGriff wrote:

                                      No, it doesn't! Try with an empty catch would only work the same if you surrounded each and every single line of code with it's own, independent, try...empty catch block. Not even the laziest programmer on the planet would do that...

                                      All you need is a try with an empty catch above the top level code, e.g. in a Button Click event, and all lower level code is covered. So...asking again... Should every language that has a mechanism for swallowing exceptions be pulled from the market? I don't use classic VB any more except where maintenance is needed and that is needed less and less. I do use VB.Net although I prefer C#. Both C# and Java have their share of "features" that could attract every bit as much criticism as the features that people obsess over with VB. And yet, I rarely hear those languages called into question to the same extent. There's something about that word 'Basic' that just brings out the religious zealots on both sides of the debate. To me VB has always been a tool, like a Hammer. I might feel a little sentimental from time to time, like a carpenter would about his first hammer, but it's just a tool. It has good and bad. It revolutionised Software Development and it deserves a bit more respect for that than it gets. More importantly, while it included features that allowed bad programmers to create complex code, it also included enough features to allow good programmers to write good code. Very few of the features that people are critical of were absolutely needed. Create and enforce a few coding standards and VB could be used quite well for even complex systems. The most important point to remember is that right now, out there in the wild there is code written in C# and Java that is 100 times more complex and difficult to read and maintain than anything that was produced in VB. As a profession we should have enough self respect and pride to realise that code quality is predominantly a function of the developer not the tool. Prior to college my only experience of programming was Basic. On my induction day for college back in the 90's I asked one of hte students showing us around if they used Basic at all. "Basic? That's a baby language. We use C or COBOL" When I started college I started messing with VB2.0. A few weeks later that same guy approached me and asked me if I could show him VB, he wanted to use it for one of his assignments. When I started work I used

                                      OriginalGriffO 1 Reply Last reply
                                      0
                                      • R Richard A Dalton

                                        OriginalGriff wrote:

                                        No, it doesn't! Try with an empty catch would only work the same if you surrounded each and every single line of code with it's own, independent, try...empty catch block. Not even the laziest programmer on the planet would do that...

                                        All you need is a try with an empty catch above the top level code, e.g. in a Button Click event, and all lower level code is covered. So...asking again... Should every language that has a mechanism for swallowing exceptions be pulled from the market? I don't use classic VB any more except where maintenance is needed and that is needed less and less. I do use VB.Net although I prefer C#. Both C# and Java have their share of "features" that could attract every bit as much criticism as the features that people obsess over with VB. And yet, I rarely hear those languages called into question to the same extent. There's something about that word 'Basic' that just brings out the religious zealots on both sides of the debate. To me VB has always been a tool, like a Hammer. I might feel a little sentimental from time to time, like a carpenter would about his first hammer, but it's just a tool. It has good and bad. It revolutionised Software Development and it deserves a bit more respect for that than it gets. More importantly, while it included features that allowed bad programmers to create complex code, it also included enough features to allow good programmers to write good code. Very few of the features that people are critical of were absolutely needed. Create and enforce a few coding standards and VB could be used quite well for even complex systems. The most important point to remember is that right now, out there in the wild there is code written in C# and Java that is 100 times more complex and difficult to read and maintain than anything that was produced in VB. As a profession we should have enough self respect and pride to realise that code quality is predominantly a function of the developer not the tool. Prior to college my only experience of programming was Basic. On my induction day for college back in the 90's I asked one of hte students showing us around if they used Basic at all. "Basic? That's a baby language. We use C or COBOL" When I started college I started messing with VB2.0. A few weeks later that same guy approached me and asked me if I could show him VB, he wanted to use it for one of his assignments. When I started work I used

                                        OriginalGriffO Offline
                                        OriginalGriffO Offline
                                        OriginalGriff
                                        wrote on last edited by
                                        #32

                                        Richard A. Dalton wrote:

                                        All you need is a try with an empty catch above the top level code, e.g. in a Button Click event, and all lower level code is covered.

                                        It's not the same: On Error Resume Next causes execution to continue from the statement after the one that cased the error. An empty catch block will continue from the statement following the catch.

                                        On error resume next
                                        x = 3
                                        x = x / 0
                                        x = x + 1

                                        would give an x of 4

                                        try
                                        {
                                        x = 3;
                                        x = x / 0;
                                        x = x + 1;
                                        }
                                        catch {}

                                        would give an x of 3. To duplicate the VB:

                                        try { x = 3; } catch{}
                                        try { x = x / 0; } catch{}
                                        try { x = x + 1; } catch{}

                                        I could argue that empty catch blocks are bad, but they can be justified under some circumstances (if they are documented sufficiently)

                                        Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                                        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                        R 1 Reply Last reply
                                        0
                                        • OriginalGriffO OriginalGriff

                                          Richard A. Dalton wrote:

                                          All you need is a try with an empty catch above the top level code, e.g. in a Button Click event, and all lower level code is covered.

                                          It's not the same: On Error Resume Next causes execution to continue from the statement after the one that cased the error. An empty catch block will continue from the statement following the catch.

                                          On error resume next
                                          x = 3
                                          x = x / 0
                                          x = x + 1

                                          would give an x of 4

                                          try
                                          {
                                          x = 3;
                                          x = x / 0;
                                          x = x + 1;
                                          }
                                          catch {}

                                          would give an x of 3. To duplicate the VB:

                                          try { x = 3; } catch{}
                                          try { x = x / 0; } catch{}
                                          try { x = x + 1; } catch{}

                                          I could argue that empty catch blocks are bad, but they can be justified under some circumstances (if they are documented sufficiently)

                                          Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                                          R Offline
                                          R Offline
                                          Richard A Dalton
                                          wrote on last edited by
                                          #33

                                          OriginalGriff wrote:

                                          It's not the same: On Error Resume Next causes execution to continue from the statement after the one that cased the error. An empty catch block will continue from the statement following the catch.

                                          The empty try..catch is infinitely worse than On Error Resume Next. On Error Resume Next leaves the flow of the code relatively untouched. If the Resume next is a bad idea the program flow will continue and will blow up some time later, but you can have some idea where the problem originated. Of you swallow an exception at a high level and that exception originated at a low level, you are at a complete loss. Not to mention the fact that there could be any number of Empty try catch swallows in between. But like you said the empty catch clause can be justified and so we don't slam an entire language because you can do it. Guess what, classic VB didn't have Try..Catch. It had what it had. And like empty Catch blocks if you abused what it had you could write horrible code. VB.Net and C# have better error handling mechanisms than classic VB....SHOCKER!!!! If you worked with what you had you could use things like On Error Resume Next to write good code that could be understood. There are many credible criticisms of classic VB, most of which seem to completely miss the point that VB was what it was and came from where it came. It's like blaming your 1980 Toyota for you constantly getting lost because your 1980 Toyota didn't come with built in Sat Nav. -Rd

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups