VB6 Swiss Army Knife


Consultant's guide to legacy development.

Being a consultant, once in a while I have to forgo the modern niceties of OOP, Reflection, Refactoring, etc... and jump into the client's old Visual Basic 6 code.  But the experience doesn't have to be crappy - there are a lot of free add-ins that extend in VB in various ways and speed up development.  This is the list of tools that I typically install to be productive.

  • Microsoft Virtual PC 2007.  You can't have all that COM junk funking up your consulting laptop.  I have a Windows 2000 Professional virtual machine that has all the VB6 goodness installed on it.  For these days, Win2k is unbelievably lean.  The entire OS install, all the patches, plus all the dev tools you need typically weigh in at no more than 3-4 GB.  The price: free.
  • VMware Workstation or VMware Player.  Same as above, but if you have to work with hardware (like USB devices or comm ports), this is your best bet, as Microsoft's tool does not support anything external really.  VMware Workstation prices range, while the VMware Player is free.
  • Collection Class Master Add-in.  The VB6 strongly typed collection generator.  Originally written by Francesco Balena, the tool is invaluable to OCD types like myself.
  • VB6 Mouse Wheel fix.  It's not like the mice did not have mouse wheels when VB6 came out in 1997.  But for some reason, the support did not come in the box.  The mouse wheel was only useful if you bought an MS mouse and installed the Intellimouse drivers.  That insanity came to an abrupt end, when Rob Gruen of Microsoft came up with an add-in that fixed all that.  Price: free.
  • PDSA Property Creator.  A total convenience tool - it does one thing and one thing only: create properties.  Sure, VB ships with a wizard that is supposed to do the same thing, but it sucks.  This one sucks a lot less.  Written by a well known author Paul Sheriff.  Price: free.
  • MZTools.  When VB6 was in its prime, this was the add-in to have.  That has not changed.  It's got a lot of convenience tools, it's got some refactoring tools (except we didn't it "refactoring" back then), plus some statistical analysis and auto documentation support.  Price: free.
  • ADO Stored Proc Generator Add-in. A simple VB6 add-in that generates the mindless stored procedure wrapper code.  Sweet.

author: Angry Hacker | posted @ Thursday, May 01, 2008 12:33 AM | Feedback (0)

Subtext port to MySQL - take 2


image_3 A while ago I ported Subtext to MySQL.  I've gotten a bit of feedback that suggested that the port and specially MySQL integration could be much improved.  So, I addressed a couple of issues (see below), most of them having to do with variations of MySQL installations at various web hosting companies .  As before, this is not an official version of Subtext, but simply my port from Microsoft SQL Server to MySQL.  Here is the good stuff:

Downloads:

Installation (2.84 MB)
Source (22.7 MB)

Fixes:

Removed the extra unneeded files
Fixed the location of the MySQL provider
Subtext now accounts for whether MySQL is case sensitive
Subtext now comes with a MySQL provider that supports medium trust
Added more debugging information during installation

Minimum Requirements

MySQL 5.x. 
Anything else that regular Subtext requires.

GoDaddy issues

Seeing how almost every issue that was reported to me revolved around GoDaddy, here are easy 20 steps to blogging with Subtext for MySQL:

  1. Login to GoDaddy
  2. Go to Hosting & Servers menu, then pick My Hosting Account.
  3. Click on the Open link.
  4. From the Content menu, pick IIS Settings and create a folder. 
  5. Give the folder Set Application Root and Anonymous Access permissions.
  6. From the Content menu, select File Manager, check the newly created folder, then click on the Permissions button.  Uncheck Inherit, then give the folder read/write permissions.
  7. Go to Databases menu and select MySQL, then click Create Database button
  8. For version, pick 5.0.  Give the database a name.  Note that the User ID for the database and the Database name will be the same.
  9. Go into Edit/View Details of the database and you'll see various information.  Stay on this page, while doing the next set of steps.
  10. Unzip the Installation file you just downloaded from this page and upload the contents into the folder you just created in your hosting account.
  11. Open the web.config (that resides in the folder you've created) in your editor of choice. 
  12. Search for the following line: <add name="subtextData"  connectionString="Server=YOUR_SERVER;Database=YOUR_DB;User ID=YOUR_USER_ID;Password=YOUR_PASSWORD" />
  13. Ok, remember all the way back in the step 9, I told you stay on that page.  Great. 
  14. Replace YOUR_SERVER with Host Name (from the web page). 
  15. Replace YOUR_DB with Database Name
  16. Replace YOUR_USER_ID with User Name
  17. Replace YOUR_PASSWORD with whatever password you assigned yourself for the database.  Great, the part for identifying the database is done.  Let's move on.
  18. Search for the following line:  <trust level="Full" originUrl=".*" />
  19. Comment this line out.  That means place <!-- in front of the line and --> at the end of the line.  So it should look like this:  <!--  <trust level="Full" originUrl=".*" /> -->  Why?  Because for whatever reason, GoDaddy no likey when someone tells it under what trust level to run.  So even if you set it to Medium or Low or whatever else, the site will still barf. 
  20. That's it.  You are ready to start blogging.

Troubleshooting

If the site still does not work, you can try these steps to get to the real error.  If you are still having issues, shoot me a message via the Contact link at the top.

author: Angry Hacker | posted @ Sunday, March 30, 2008 12:38 PM | Feedback (0)

Airlines, Users and UI Follies.


Airport Kiosk Recently I was talking to my relative who works at the American Airlines counter at the airport.  He was telling me that the kiosk computers, that are in most airports now, haven't made a dent in how busy the counters are.  Bottom line, he says, is that people are afraid of using computers.

I have a totally different opinion.  Just happened to fly a bit ago and used a kiosk to get a boarding pass.  My opinion is that the User Interface is ALL wrong and that is what scares people off. 

Problem #1. The starting page had 4 or 5 big touch buttons on it.  There was "Get a boarding pass", "Change seat assignment", "Change meal type", etc...  If you think about, 95% of the people are there to get the effing boarding pass.  The other 5%?  Who cares, that's why airlines have people at the counter - to handle edge cases.  Why confuse the 95% with other buttons.  The simple solution is crying out to be implemented.  Have a gigantic button, that takes 3/4 of the screen real estate, inviting you to get a boarding pass.  Even if you want the kiosk to handle other requests, there is nothing wrong with placing a small link in the bottom right that takes you to "Other Services".

Problem #2.  For identification, the kiosk asked me to provide a driver's license or a credit card.  Ok, no problem.  However, it wanted to me place it into an ATM style slot (e.g. it sucks the driver's license in wholly).  So, let's see, 5 minutes before my boarding time, I am supposed to trust a computer I've never seen and just blindly believe that I'll get my ID back?  Sorry, I've seen enough bugs in even most well written programs to know that sh*t happens.   How about providing a grocery style or swipe type of identification system. 

No wonder, nobody is using the kiosks.

author: Angry Hacker | posted @ Saturday, December 15, 2007 1:54 PM | Feedback (0)

Ok, you don't like Acrobat. I get it.


Overheard from the discussionon Slashdot about PDF and Adobe Acrobat:

NOOOOO!!! please not another upgrade. It nags me three weeks before an upgrade. NO, I DONT WANT TO FUCKING UPGRADE!!! And three weeks after an upgrade. I ALREADY FUCKING UPGRADED IT!!! Then it resets all my file extension defaults and starts opening everything in Acrobat Reader 8 even though I've told it a million times to open with Acrobat Pro 5. Fucking piece of shit must die.

Note to Acrobat developers, if anyone asks what you do, lie. It could be me. I will fucking kill you and then skull fuck you. I will kill your fucking family and skull fuck them. I will kill your fucking pets and skull fuck them. I will burn your fucking house down and find a way to skull fuck that too. And no jury will convict, they'll wish they had gotten to you first.

Sorry. The first hundred pages of my shit list are devoted solely to Acrobat. Deep breaths, deep breaths.

author: Angry Hacker | posted @ Wednesday, December 05, 2007 8:33 PM | Feedback (1)

Kids say the darndest things. Episode 3.


image We are sitting at the pool with some friends of ours.  My 4 year old son is chatting with a buddy of his. 

His friend is excitedly telling my son about the last visit to the restaurant:

"You won't believe who I saw.  Kobe Bryant !!!"

"Really?", replies my son.  "And I saw french fries and chicken nuggets."

author: Angry Hacker | posted @ Thursday, November 15, 2007 11:15 PM | Feedback (0)

Kids say the darndest things. Episode 2.


imageMy wife is dressing my 3 year old boy. 

As she is putting a white T-shirt on him, she says: "Today, you'll wear a plane T-shirt". 

My kid looks at the T-shirt and asks: "Where is the plane"?

author: Angry Hacker | posted @ Tuesday, November 13, 2007 11:19 PM | Feedback (1)

In defense of Vista


It does NOT suck.

If you read some forums or blogs, you'd think that Vista crashes daily and eats your kids for breakfast. A quick Google search reveals that, at this point, it's become fashionable to bitch Vista out. 

Vista, in fact, does NOT suck.  Those people are smoking crack. Or they are not using it.  It's a pretty good upgrade to XP (itself a great OS) and is definitely up there in comparison with other operating systems.  So let's address some of the criticisms. 

Why it's a great upgrade to XP.

XP is a good and stable OS, but it is showing it's age.  For instance, to run XP in any sane manner, you have to install a bunch of software, like Google Desktop, various utilities, etc...  All this just to start being productive.  In Vista, you are one key strokeimageaway from being productive.  You press it and you are at the command prompt, being able to access/run/search whatever you want on the computer.  Just this one feature is such a gigantic productivity win that everything else pales by comparison.  The integrated search really, really works well and seems to have been designed by someone with a very good sense of usability.  No need to install Google desktop anymore. 

Why else?  The OS just looks great, is pretty snappy and is pleasant to use. The eye candy, is just the right level and does not do any superfluous tricks like, say, Compiz Fusion.  

Other noteworthy items:

  • ReadyBoost - You already have a spare USB key, so pop it in and see some real speed up.  I ended just buying extra RAM because I need to run VMs, but it's nice to know that the feature is available. 
  • Media Center - Ok, you could get it for XP, but you had to get the Windows XP Media Center Edition, which was dumb and a pita.  With Vista, all the goodness is in the box.
  • All the stuff you don't have to install - How about never having to install a proprietary photo application?  The built in Photo Gallery is sweet; better integrated than any 3rd party photo management application I've ever seen and certainly better than iPhoto on my wife's MacBook.  Lot of people don't realize that, for the first time, Windows comes with a set of truly usable utilities: Calendar, DVD Maker, Movie Maker, Voice Recognition, etc...
  • Device support - Some devices still don't have drivers, but the built-in ones are simply awesome.  For instance, on Windows XP, I had to install a 300 MB driver for my wireless HP printer, which no doubt, included a lot of crapware.  With Vista, no new drivers were required and it literally picked my printer out of thin air.  Sweet.

The OS is really stable as a rock.  I've been using it since February and it crashed exactly one time.  I tried to see how far I can push the OS in terms of CPU and memory overload. I opened up hundreds of applications and pushed the OS deep into the virtual memory territory.

Bitch Fest

As you read some of the forums people bitch about a lot of shite, mostly because they don't know what they are talking about or are too lazy to google for the answer.

  • Vista uses too much memory - Why shouldn't it all your memory?  You got some other OS running on this box at the same time?  Actually Vista caches your memory.  In other words, it tries to anticipate what you are going to do and have it ready for you.  Look it up - it's called SuperFetch.
  • Excessive prompts/UAC - If it bothers you, turn the effing thing off.  It bugged me, so after I while I nixed it.  Then I read a note from Tim Sheath and I turned it back on.  His trick allows you to keep some of the UAC benefits while never being bothered with a prompt again. 
  • Incompatible apps - Most of the apps I had, in fact, were compatible and I am a developer (thus I have a bunch of weird low-level stuff). If something does not work, most likely it can be fixed by running it as an admin user.  Right-click, select run as Administrator.
  • Too slow - No, it's not.  Your computer is too slow.  Vista is not meant to run on a 5 year old machine.  Neither Gutsy Gibbon or Leopard or any other modern animal.  You are going to need a new machine or at least some new components.  As long as you want to see Aero, that is.
  • Blah, blah, blah - It's been fixed via Windows Update.  Like the infamous "Calculating time remaining" and the Control Panel disappearing act.

What sucks about Vista

That said, Vista could use some substantial improvements.  I have a short list:

  • The All Programs menu is sandwiched in 2 inches of screen real estate.  I install a lot of apps and don't want to scroll 'till tomorrow to see the them.  Let the menu fly free or come up with another paradigm.  This is really my only UI related complaint.
  • Vista already comes in 20 different editions.  How about adding a "developer" edition which comes preloaded with all the tools developers have to download anyway (all the sysinternals stuff, reflector, NUnit, NAnt, popular vs addins, firefox, filezilla, paint.net, etc...).
  • There aren't any good tools for developers to easily take advantage of the graphical glass goodness.  MS released Blend, but I have to go to Photoshop school first to even begin to understand how to make a pulsating gradient.  How about a snazzy API that developers can understand? Like, Button btnOk = ButtonFactory.CreatePulsatingGradient(), while somebody comes up with a brilliant tool to bring developers to the graphics artist level. 
  • The awesome potential of the combination of MediaCenter and CableCard technologies is nowhere to be seen. (This seems like a perfect application for a Mac Mini though).  That's probably not Microsoft's fault - I am guessing the cable companies are probably dragging their feet on this, but still it sucks.

Overall, despite a couple of blemishes, Vista is pretty great. 

author: Angry Hacker | posted @ Sunday, November 11, 2007 11:53 PM | Feedback (22)

Kids say the darndest things


So I walk into Toys 'R Us with my son (7 yrs old) and my daughter (3 yrs old).  Immediately, I set expectations: "Ok, you can each get only ONE toy.  So pick wisely." 

In about one minute, my daughter grabs a Polly Pocket doll off the shelf and says: "Can my brother get this"?

author: Angry Hacker | posted @ Sunday, November 11, 2007 8:00 PM | Feedback (0)

Subtext ported to MySQL


imageAfter a couple of months of putting in an hour here and two there, I've finally ported Subtext to MySQL. Note, that this is NOT an official Subtext release

This post is a digital catharsis of sorts. It's an attempt to "out" some of the knowledge I've gained from the port.  And someday, when I forget all about the port, this post might serve as a reference for why I did something that seems dumb. But first things first.  While we figure out where the source should reside, here are the downloads.

!!! UPDATE - March 30, 2008 !!!

I've released an update.  Download the software here instead.

Downloads:

Binaries (3.69 MB)
Source (22.7 MB)

Minimum Requirements:

MySQL 5.x - previous versions did not support stored procedures.
Anything else that the regular Subtext requires.

Help

If you need help/support, either post on the Subtext Open Discussion or hit me up via the Contact link in the upper right corner.

The Port

I ported the 1.9.5 version of Subtext, along with the recently released security patch.  The solution structure remains the same, except for the extra project (MySQL port of the Microsoft Data Application block).

When I started out, I was contemplating on porting the Subtext 2.0 trunk code.  But there was too much turbulence there.  Eventually I settled on a strategy of modifying version 1.9.5, because it was already done/baked/released/written in stone.  This decision turned out to be the right one, because the Subtext team temporarily gave up on the 2.0 branch in favor of a smaller 1.9.6 release. 

The idea was to use the 1.9.5 port to learn the code, learn MySQL and use the knowledge in the later versions.  Another strategy was to change the Subtext code and its structures as little as possible.

I've documented various issues that I ran into with MySQL a while ago.  One of the more onerous problems is that anytime you request a COUNT(*) from MySQL, it returns a long (int64) data type, but Microsoft SQL Server returns an int  (int32).  Subtext, of course, expects an int, which led to hacky code like this:

entry.FeedBackCount = Convert.ToInt32(ReadInt64(reader, "FeedBackCount"));
 

On the whole, Subtext is actually is a very good shape.  It's well commented and the coding style is very consistent for an OSS or an in-house project.

Having said that, the data layer is not very friendly to databases other than Microsoft SQL Server.  Initially, when I surveyed the code, I thought that I could write the a MySQL data provider, plop it into the solution, do the dependency injection thing and pat myself on the back.  As it stands, right now that's not possible. The main problem is that the data layer leaks references all over the place. 

In other words, just because the data layer is using System.Data.SqlClient to interface with a data store, why should the business layer know about it?  But currently it does, because the data layer expects parameters whose types reside in the System.Data.SqlClient namespace.  There are helper classes which are dependent upon SqlClient as well.  In addition, the exceptions are propagated as SqlException objects, with code looking for certain values in the exceptions and acting accordingly.

The solution to Data Layer woes is to push it deeper into isolation.  Hopefully, at some point, I'll spend some time to make Subtext more hospitable to other databases.

So the solution for now was to simply rip out SqlClient and MS Application Block and replace it with MySQL analogs.

Miscellaneous

Unit tests don't run.  I haven't ported them yet.  Simply no time at this point. 

Subtext performance against the MySQL database is basically on par with MS SQL version, according to my completely unscientific observations. 

author: Angry Hacker | posted @ Tuesday, November 06, 2007 6:37 AM | Feedback (8)

Subtext to MySQL progress report


together at sea While Mr. Haacked and company fight emergencies, I've been making some progress with Subtext's MySQL port.  So here is what is done so far.

All SQL has been converted to MySQL.  The effort was actually pretty enormous, considering time constraints.  There were 7 installation files full of CREATE TABLE scripts. 

And then there were 90 stored procedures.  Two thirds of stored procs converted with minor tweaking.  Some, particularly ones that fetch paged data were greatly simplified, thanks to MySQL LIMIT command.  And a few had to be basically rewritten.  All in all, good learning experience in MySQL.  Compared to the original, Stored Procedures.sql file has lost 32 kb, mostly because getting paged data did not require the complexity that the MS SQL Server requires.

Next I converted Microsoft Application Data Block to MySQL.  This was fairly easy.  The only hickup I experienced is that initially I renamed SqlHelper class to MySqlHelper.  Well, it turns out that the MySQL ado.net provider already has a MySqlHelper class.  In it, they implemented a small subset of the Application Data Block.  Unfortunately, it was not the subset that Subtext is using.  So my class is called MySqlHelperEx.

Then I methodically ripped out of Subtext all the MSSQL related goodness and replaced it with MySQL equivalents.

Ripped out Replaced with
SqlClient MySQL provider
Microsoft Application Data Block MySQL Application Data Block
Calls to SET NOCOUNT ON Not needed on MySQL
Stored Parameters starting with @ MySQL can't handle parameters starting with @, so had to replace it with _ (underscore)
nvarchar, ntext, int, etc... Equivalent types 

There are also a ton of other little, tiny differences that make writing database agnostic code difficult.  For instance, SELECT COUNT(*) as TotalRecords returns INT on MSSQL, but LONG on MySQL.

Another rather annoying problem is that MySQL does not support default parameters, while Subtext makes a fairly liberal use of them.

What Works So Far.

I got the installation working well.  Blog comes up and I can configure it fine.  From there things get a bit dicey.  There are exceptions here and there, probably due to the use of default parameters.

author: Angry Hacker | posted @ Thursday, September 27, 2007 10:34 PM | Feedback (4)