Viva la VB!
Hi, my name's Karl, and I use Classic VB. My "problem" is, you see, Classic VB still does the job for me. In some circles, it's hard to feel more of an outcast and down on your luck than to be one of those Luddites who haven't yet adopted the inevitable. Thankfully, those circles are mighty tight -- some might stoop to calling them inbred -- and easy to avoid out here in the real world.
Long-time readers might remember that I used to write a variety of columns for Visual Studio Magazine (and its predecessor, Visual Basic Programmer's Journal) focused on practical problem solving. Apparently, there are still a lot of folks (see Figure 1) out there still running into practical problems with Classic VB, so Patrick has asked me to return with a focus on, uh, okay, won't call it "the past," but...
There are new challenges in the world of Classic VB, and probably none is as daunting as supporting Vista. (Insert mental joke here about Microsoft's troubles -- not even I'm that gratuitous. [O rly? -- Eds.]) I hope to start off this column with a series of practical articles revolving around getting VB6 to run on Vista, including the latest service packs, and actually progressing to the point of being productive.
Once we have VB6 up and running, we'll turn the focus to Microsoft's promise of support for the runtime, the IDE, and numerous other components, making sure that native VB code runs as it should. And it wouldn't be a Vista discussion at all if we didn't plumb the mysteries of the dreaded security model, and ways to get around, or otherwise live with, it.
[Click on image for larger view.]
Don't care at all about Vista? (You're far from alone there!) Don't worry. I'm only focused on it at the moment because there does seem to be a need to get some baseline survival information out there. I plan to return to the practical, drop-in ready, solutions that folks seemed to enjoy most in my old columns.
Don't Hose That Hardware
To get us started on the path to supporting Vista, or really any other operating system you'd really rather not actually install on useful hardware, I'll recommend heartily a new tool that Microsoft has recently decided to provide totally free -- Virtual PC 2007. Get it. No single tool, in my recollection, has ever made life easier for the multiplatform developer.
It didn't take me long to realize just how useful VPC is. In the first week of playing with it, I had virtual machines (VMs) built for platforms ranging from Windows 3.1 to Vista, and everything in-between. I could easily test any of the code on my hard drive, using a single KVM set! I can run identical tests in Windows 95 and XP or Vista by just Alt-Tabbing between windows. Absolutely amazing and totally liberating.
The first thing you'll want to do when setting up a VM, upon finishing the installation of a new operating system, will be to install the Virtual Machine Additions. Without these, the mouse becomes captured by the VM. (To escape this mouse capture, during installation, hold down the right Alt key while moving the mouse outside the VM window.)
Probably the coolest feature of all is that you can set a VM to use "Undo Disks" -- that is, nothing is committed to the virtual hard disk (VHD) image(s) until you close down the machine, and you are asked whether to write the changes. This allows you to boot to a "clean machine" at will. Just burn copies of your VHDs to DVD as soon as you feel they are ready to serve as a baseline platform. There are tutorials on the Web that describe how to optimize and reduce the final archived VHD size, but the basics are:
- Attach to the VHD from a distinct VM, so that it's drive D:
- Delete the swap file (it will be recreated when needed).
- Defragment the VHD.
- Run VPCs "Virtual Disk Wizard" against the VHD to compact the image.
Back to the Future?
I will not be writing about Anything .NET in this column. When I make references to VB, you can be assured I'm speaking of the Classic variety -- VB6 and earlier. If I find need to refer to latter bits that bear that name, I'll call it by something (Fred?) that will leave no confusion in your mind what I'm speaking of. Until next time...
About the Author
Karl E. Peterson wrote Q&A, Programming Techniques, and various other columns
for VBPJ and VSM from 1995 onward, until Classic VB columns were dropped entirely
in favor of other languages. Similarly, Karl was a Microsoft BASIC MVP from 1994
through 2005, until such community contributions were no longer deemed valuable.
He is the author of VisualStudioMagazine.com's new Classic
VB Corner column. You can contact him through his Web
site if you'd like to suggest future topics for this column.