Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is probably the cleanest VB 6 I've seen.

Do notice Option Explicit. That is like disabling 90% of the magic that causes unmaintainable code.



The IDE has a setting to always turn it on for new projects. That was a setting I always enabled on new installs. Along with a switch to use SDI instead of MDI.


> Along with a switch to use SDI instead of MDI.

You monster!


Wait till you find the assembly code hidden in a list of hex numbers that gets copied to a function and then called as a thunk ;-)


I remember the feeling when you see a module and it has an "On Error Resume Next" at the start.


In my first job, I was given a VB6 project to maintain which had a mixture of "Option Base 1" and "Option Base 0" (or unspecified, this being the default), with occasional "On Error Resume Next". This specifies the index value for the first item in an array, i.e. you could choose the default European building floors (ground floor is 0) or American floors (ground floor is 1) -- per module!

I had to convert everything to "Option Base 0" before I could start fixing the reported bugs, it was far too confusing following the arrays passed between modules being indexed starting at 0, then 1, then 0 etc.


Would not the UBound and LBound functions not solved those issues?


Yes, though I didn't know they existed.

The existing code was written with 0 or 1 as required (except where there were bugs), and frankly I think it's was better anyway to use 0 everywhere rather than LBound(x).


That’s basically how shell scripts behave by default. At least in VB it’s not the default.


Yes, but shell scripts are written on that assumption. VB code usually wasn’t.


I wish I had known this back in the day.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: