VB 6
-
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 SubA correct answer was stored in a global vari
-
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 SubA correct answer was stored in a global vari
oh fat cannon! :omg: Yes, this confirms my oppinion. VB6 is the language with the most chaotic code i have ever seen. It's really a language for small short-life stuff. For those who never where in that situation: Imagine if you have a project with code like this in this language, but with 100000 source code lines...
-
oh fat cannon! :omg: Yes, this confirms my oppinion. VB6 is the language with the most chaotic code i have ever seen. It's really a language for small short-life stuff. For those who never where in that situation: Imagine if you have a project with code like this in this language, but with 100000 source code lines...
Umm ... seems to me that the major coding horror of the OP's snippet is not that it's written in VB6, but that none of the variables are given meaningful names, there's no structure, etc. The same horror could just as easily have been written in C#, etc., and the only thing you'd see differently is {} instead of THEN ... ELSE ... ENDIF, a few () scattered around, and '||' instead of 'OR', etc. Not that I'd go out of my way to find a VB (6, .Net or other) job, of course.
-
Umm ... seems to me that the major coding horror of the OP's snippet is not that it's written in VB6, but that none of the variables are given meaningful names, there's no structure, etc. The same horror could just as easily have been written in C#, etc., and the only thing you'd see differently is {} instead of THEN ... ELSE ... ENDIF, a few () scattered around, and '||' instead of 'OR', etc. Not that I'd go out of my way to find a VB (6, .Net or other) job, of course.
Chris Trelawny-Ross wrote:
find a VB (6, .Net or other) job,
Some times they find you. :sigh:
-
Umm ... seems to me that the major coding horror of the OP's snippet is not that it's written in VB6, but that none of the variables are given meaningful names, there's no structure, etc. The same horror could just as easily have been written in C#, etc., and the only thing you'd see differently is {} instead of THEN ... ELSE ... ENDIF, a few () scattered around, and '||' instead of 'OR', etc. Not that I'd go out of my way to find a VB (6, .Net or other) job, of course.
-
oh fat cannon! :omg: Yes, this confirms my oppinion. VB6 is the language with the most chaotic code i have ever seen. It's really a language for small short-life stuff. For those who never where in that situation: Imagine if you have a project with code like this in this language, but with 100000 source code lines...
Bigdeak wrote:
Yes, this confirms my oppinion. VB6 is the language with the most chaotic code i have ever seen. It's really a language for small short-life stuff. For those who never where in that situation: Imagine if you have a project with code like this in this language, but with 100000 source code lines...
VB6 isn't perfect, but it didn't come fitted with a gun that pops out of the screen that forces you to write crap code. Today, the most chaotic code I see is in VB/ASP.Net apps. And most of it knocks anything I ever saw in VB6 out of the ballpark. And yet with both VB6 and VB.Net you can write beautiful elegant code. So, why is there so much crap code out there? Well...you're right. It is VB's fault. VB made it possible for non programmers to program. Which means it made it possible for bad programmers to program. The fact is, you see so much bad code in VB and VB.Net precisely because they are both such incredibly well implemented development tools. The language isn't the problem, it's the numpty between the keyboard and the chair (no offence to the OP). You will always see the worst code in the development tools that most appeals to the masses. And the same simple fact has always been true. Good programmers write good code. Bad programmers write bad code. Suggesting that the language has anything to do with it is like advising a Spanish poet to learn English because you can write better poems in English.
-
Not hurt in the slightest. No apology needed. :doh:
-
Bigdeak wrote:
Yes, this confirms my oppinion. VB6 is the language with the most chaotic code i have ever seen. It's really a language for small short-life stuff. For those who never where in that situation: Imagine if you have a project with code like this in this language, but with 100000 source code lines...
VB6 isn't perfect, but it didn't come fitted with a gun that pops out of the screen that forces you to write crap code. Today, the most chaotic code I see is in VB/ASP.Net apps. And most of it knocks anything I ever saw in VB6 out of the ballpark. And yet with both VB6 and VB.Net you can write beautiful elegant code. So, why is there so much crap code out there? Well...you're right. It is VB's fault. VB made it possible for non programmers to program. Which means it made it possible for bad programmers to program. The fact is, you see so much bad code in VB and VB.Net precisely because they are both such incredibly well implemented development tools. The language isn't the problem, it's the numpty between the keyboard and the chair (no offence to the OP). You will always see the worst code in the development tools that most appeals to the masses. And the same simple fact has always been true. Good programmers write good code. Bad programmers write bad code. Suggesting that the language has anything to do with it is like advising a Spanish poet to learn English because you can write better poems in English.
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]
-
Bigdeak wrote:
Yes, this confirms my oppinion. VB6 is the language with the most chaotic code i have ever seen. It's really a language for small short-life stuff. For those who never where in that situation: Imagine if you have a project with code like this in this language, but with 100000 source code lines...
VB6 isn't perfect, but it didn't come fitted with a gun that pops out of the screen that forces you to write crap code. Today, the most chaotic code I see is in VB/ASP.Net apps. And most of it knocks anything I ever saw in VB6 out of the ballpark. And yet with both VB6 and VB.Net you can write beautiful elegant code. So, why is there so much crap code out there? Well...you're right. It is VB's fault. VB made it possible for non programmers to program. Which means it made it possible for bad programmers to program. The fact is, you see so much bad code in VB and VB.Net precisely because they are both such incredibly well implemented development tools. The language isn't the problem, it's the numpty between the keyboard and the chair (no offence to the OP). You will always see the worst code in the development tools that most appeals to the masses. And the same simple fact has always been true. Good programmers write good code. Bad programmers write bad code. Suggesting that the language has anything to do with it is like advising a Spanish poet to learn English because you can write better poems in English.
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... adouble
). 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
-
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]
Doesn't improve spelling much though, eh?
-
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... adouble
). 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
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 ;-)
-
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 SubA correct answer was stored in a global vari
I worked on VB6 for some three years, and while I did see a lot of ugly code, I never found the language itself (or its IDE for that matter) to be particularly at fault. Sure it missed a decent array initialization mechanism, and its concept of "object-orientation" was laughable when compared to Java - but between a couple good practices (such as always using Option Explicit to enforce variable declaration) and a bit of boilerplate code to abstract away the worst idiosyncrasies, it wasn't bad at all to program; I for one didn't find it any more hard to program modular, loosely-coupled, highly-cohesive classes in VB than in Pascal. Perhaps VB's ugly code base was more a consequence of the target public it was aimed at? Microsoft marketed it as a tool for novice programmers to write simple applications with, so it's no wonder we find a lot of bad code written in VB.
-
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 SubA correct answer was stored in a global vari
I remember my early days in programming. I started with VB5 at the age of 15. Oh my... The fact that I didn't need to declare a variable simply knocks me out today. I remember when I realized that this was really bad, I remembered to always use "Option Explicit". The more I got skilled in programming the farther I got away from VB. It was like a calling to code horrors. Soon enough though, I abandoned VB two to three years later in favor of C++. The fact is that VB draws many people who either are not born to code or suck at coding because they are just starting.
-
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 SubA correct answer was stored in a global vari
VB should just be put out of it's misery !
-
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 ;-)
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 SelectThis 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. -
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 ;-)
on error goto Shoot_Foot
-
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 SubA correct answer was stored in a global vari
-
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 ;-)
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.
-
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 SubA correct answer was stored in a global vari
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!
-
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... adouble
). 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
3. VB has an integer division operator:
9 \ 4
returns2
, not2.25
. 4. Propagating the null value in expressions is correct. Technically, there is a difference betweenDim a As Variant
a = long_expression_possibly_returning_null
If a = True Then
some_code
Else
more_code
End Ifand
Dim a As Variant
a = long_expression_possibly_returning_null
If a = True Then
some_code
ElseIf a = False Then
more_code
End IfAnd 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. DefaultByRef
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.