Author Archives: admin

Visual Basic and line numbers

2
Filed under Utilities, VB Feng Shui

I’ve seen lots of rants over the years saying things along the lines of

Who wants to use a language that looks like this:

10   Print "Hello, World"
20   If x = 1 Then Goto 50
30   Print "Something else"
50   Print "Result was 50"

Or similiar nonsense. Of course, VB only vaguely resembles this style of code anymore, but one thing has remained virtually the same. Line numbers.

If I remember correctly, in BASCOM and BASICA, they were required. Then Basic Professional Developer System (MS BasicPDS) came out and line nums were no longer necessary, but you could still use them if you liked (probably more to be backwardly compatible with all that old BASICA code).

In all the older VBs (pre .NET days), you actually had to add line numbers to the source code itself in order to get them into the program and refer to them (via the ERL function). While this was certainly doable, the resultant code ended up looking like some seriously old-school mash you wouldn’t want to be caught dead delivering (or trying to maintain).

However, being able to report a line number during an error at runtime, at the client site, so it can be logged or reported back to you as a developer is damn near invaluable. Microsoft recognized this enough in .NET to include line number support built in to the error stack and handling subsystem (although the old style line numbers in code and ERL function still work, appearently).

That’s great for .NET, but there’s still a lot of VB6/5 and older code laying around that has to be maintained. So what do you do?

Ages ago, I built a little command line utility to run through every module in a VBP file (and every module of every project in a VBG file, too), and either add or remove line numbers. It output all the files to the same directory, but with “LINED_” prepended to the file name. This tactic makes it very easy to simply DEL LINED_*.* when you’ve compiled the line numbered project to clean things up and not leave line numbered code sitting around. You can run it against individual BAS, FRM, CTL, DSR, CLS, etc files, but if you point it at a VBP or a VBG file, it’ll even rewrite that file so that it’s contents point to the new file names. This makes it very easy to construct a batch file to 1) line number a project, 2) compile it, and 3) kill off the line numbered source files.

For instance, this batch file:

set pfile=%~dpn0
set pname=%~n0
set pdir=%~dp0
vbliner %pfile%.vbp
VB6.EXE /m "%pdir%LINED_%pname%.vbp"
del "%pdir%LINED_*.*"

Just name it the same name as a VBP file, save it to the same folder as your VBP file, and run it.

It will pull the file name and path from the name of the batch file itself (which should be the same as the VBP you want to compile), line number the project, compile it, then delete the line numbered source files when fnished, leaving you with a nice compiled file, completely line numbered but with none of the mess.

Its other nifty trick is to line number the lines using the same algorithm that the VB6 IDE uses to display line numbers as you move through code, as in:

This one trick (which I haven’t seen in any utility to line number VB source), makes it so that you don’t have to keep the line numbered source around so you can refer to it later. Somebody calls up saying they get an error in Module XYZ, line number 10202, all you have to do is pull that version of the module from SourceSafe (you do use version control of some kind, right?), load it up in VB and jump to the given line number. Can’t get much simpler.

VBLiner starts numbering at 10000, the rational behind that being that if you happen to need to include a hardcoded line number in your code for some reason, the automatic numbers hopefully won’t interfer with your hand coded numbers.

Another handy tip. Once you’ve opened your VB project, Right click the project explorer, select ADD, then ADD FILE. Find the BAT file that you just created above, and be sure and check the “Add as Related Document” box before adding it to your project. Now, then, you should be able to simply DBL CLICK on the BAT file from the VB project explorer to run the bat file and compile your project, complete with line numbers, all automatically.

And a final note; VBLiner does ostensibly support removing line numbers from VB files as well, but I’ve never had much use for that facility, so it’s not well tested. As with any freeware, use at your own risk. And it should go without saying, Back up your source files before running it on them.

Download a zip of the utility here and let me know what you think.

VB Swiss Army Knife

7
Filed under Utilities, VB Feng Shui

VB has one of the best IDE’s around. Sure Eclipse is pretty capable, Delphi is quite slick, and for the purists, editors like SlickEdit can make you almost believe you’re coding in an IDE.

But VB’s IDE is the one to beat. And it has been since VB3.

But even the best have issues; mistakes, ommisions, things that jsut could have been so much better.

And that’s where MZTools comes in.

If you haven’t already played with it, download a copy and install it now. Carlos originally built MZTools for VB6 way back when, and that version was (and still is) a free utility. He’s branched out to supporting Visual Studio .NET now, and the newest version is not free, but it is worth every penny.

Take a look at the features page for version 3 (which supports VB6). The Code Review, Code Templates, and Error Handler Templates are gauranteed to save tons of time.

Personally, I don’t like his line numbering support. I feel like the line number applied to a line should be the same as the actual line number in the file, as reported by the VB6 editor, like this:

That way, you don’t have to retain the numbered version of the source to be able to refer back to a specific line number. However, this is a pretty minor nitpick.

In short, MZTools is a massively handy utility to have on you’re VB menu bar. Definitely for VB6 (cause it’s, well, free), and worthy of consideration for .NET.

Outlook Signatures

2
Filed under Office, Utilities

On a lark a few days ago, I decided I’d like to have random rotating quotes appended to my outgoing emails. I use GMail for mail preview (and access when I’m away from my desk), but usually, I use Outlook when I’m at my desk.

Supporting random email signatures in GMail is a topic for another day, and I’ve honestly not even investigated it at all.

But Outlook. Surely, I thought there must be a free little utility to do that out there.

Well there are a few, but most aren’t free, and the few that are, aren’t particularly well built from what I can tell.

The one free one I did see that seemed to hold promise was QLiner. After a quick install, and then converting some quotes to a plaintext file, I fired it up and set things up.

It works, but it seems finicky to me. For one, it doesn’t actually template out the signature, so much as it completely replaces the existing signature with a rebuilt version (with the new quote) on a configurable timeout. So if you sent 3 messages within 5 minutes, and the timeout was set to 10 minutes, it’s likely all 3 messages will have the same quote.

Plus, it seemed to just “stop working” after a time. I never could see a pattern to this, but, invariably, after a few days, I’d notice that the signature wasn’t changing anymore. Stopping and restarting the program fixed it each time, but that’s not the hallmark of a solid app.

In the end, I uninstalled it, and I believe I’m going to throw my hat in the ring on this one.

I’m calling it Sig-Licious. The idea is that it is a simple COM Outlook addin that monitors for new email creation events, intercepts it, and parses and replaces keywords in the signature with specific bits of info.

For instance, {Date}, {Quote}, {QuoteAuthor}, {CurrentTrack} (ie what piece of music you’re listening to right now, if any), etc, etc.

Any thoughts on what other variables might be nice? To totally geek it up, how bout any ol’ Environment Var? Or the content of a performance counter at the time? Or maybe your CPU fan speed? I’m thinking various Active Directory fields might be nice, if available. Or maybe info from arbitrary Text files? Or maybe info from arbitrary posts you store in specific folders within Outlook proper.

I’ll post something when I’ve got it a bit farther than just messageboxes<g>.

Or stop me before I get too far and tell me the URL of that nifty app you’ve found that can do all this. Please!

Update

I found a few more apps out there for this. First, ADOLSign is 129$! For what is essentially a search and replace tool. Jeez.

Then there’s Exclaimer. It’s even more expensive, but does a lot more. For an enterprise setup, I could see spending a few bucks for this sort of functionality, but for your average joe, like me? Um, no.

I also just ran across Symprex Mail Signature Manager. It’s freakin’ expensive and you can only get a min 10 user license, and it appears to require Echange, but if you need something like that, it looks pretty complete.

And finally, Bells and Whistles. It’s also basically a glorified macro search and replace. 29$. Better, but still, 29$ for this?

So far, nothing for the loan gunman looking for nifty sigs. I think I’ll continue on with my little addin.

Icon Editors

2
Filed under Icons, Utilities

I had to do some icon editing recently, and did a little digging for a decent, free (or nearly free) editor that supports the new Vista and XP style icons.

I turned up AWIcons lite that looks pretty good, for a freeware version of their pro app.

Then I happened upon IconFX. Wow! It’s not quite as polished and it’s missing a few minor features, but it’s a pretty slick package.

I also looked at Axialis and IconCool, but both are commercial and in the 50-60$ range, which isn’t bad, but still.

In the end, I like AWIcons for the UI and the ability to sort the icon images within a single icon to the order necessary for XP. It’s an SDI app (meaning you can only open one icon at a time in the app), but you can open multiple instances of the app, and cut/paste works seemlessly between them, so it’s not a deal breaker.

IconFX supports more effects, hue, saturation, plus drop shadow etc, but you can’t reorder the internal images. It is MDI, though, so you can load up any number of icons simultaneously to edit. The UI is a bit clunkier, but still perfectly functional.

There’s a very good writeup of a number of the better editors here. To summarize, they recommend Axialis, followed by MicroAngelo, AWIcons and IconCool. Personally, I ran into errors after installing IconCool, so I’m not so sure about that one.

Looks like there’s hundreds more, but these seem like the most capable. Anybody know of others that are good?

Web Hosting (or Move your s**t, I wanna put my stuff here!)

2
Filed under Blogging, Misc

Ok, you’ve got a nifty idea for a site, maybe it’s personal stuff, maybe it’s something more involved. You could put it up on that free space your ISP gives you. And then you get to hassle with it every time you have to change ISP’s because Comcast gets bought by TimeWarner, that decides to bail out of your area leaving it to verizon, which…. you get the picture.

Or, you can plunk down a few bucks a year, buy a domain name and then plunk down a few more bucks a month and buy some space on a professional hosting company. That way, the domain is yours and it won’t change just because some bean counters at your ISP decide your city no longer forecasts to good market saturation, or whatever the jargon is. It also means an email address that won’t change just because you ditch cable and switch to Dish Network (say that five times fast!).

There’s a lot of hosting companies out there, and everyone has different requirements and demands as to what a good hosting company consists of. In my case, I wanted a host that would provide a decent amount of space, tons of email support, MS SQL and MySQL options, as well as Access dbs, and full support for .NET and some of the more esoteric web languages out there, like PHP, Ruby, Python, etc. so I could experiment with them, time permitting.

www.1and1.com looked pretty good, the price is definitely right, but they make you choose between Windows hosting, with .NET support and Linux hosting, with all the other languages. Not so good. But their domain registration is excellent and they provide free private DNS records, which is quite nice.

I ended up stumbling upon www.servergrid.com. They support all my requirements for 7.95$ a month, and they use HSphere for dynamic site management, which seems to work pretty good for me. I can host all my domains through one account, and just split my space up between them, which makes managing everything nice and tidy. Granted, I’m only running small sites, testing web apps, etc so I don’t have huge demands, and your mileage may vary.

This site uses dasBlog for its content management. I had it installed, setup and running within an hour on my ServerGrid space (not including the hours and hours I spent coming up with the nifty graphics, layout, CSS and color scheme, but that’s another story!)

I will say this though. I’ve started up support chats at one in the morning with these guys and there’s always someone there that seems to know what they’re doing. Good support goes a long way in my book.

Apophysis and Fractal Art

0
Filed under Apophysis, Fractals, Media

Apophysis is a “fractal flame generator”, and quite simply one of the most fascinating applications I’ve played with in quite some time.

I’m probably a bit late to the scene with fractals, and doing a google search for “apophysis fractals” will yield a literally dizzying array of different images, some absolutely fantastic and some, well, not quite so much.

Still, Apophysis is one of those programs you can sit down with and literally not look up for, say, 3 hours.

I’ve just started to play with some of the concepts and I’m nowhere near the whole post production effects that many are getting into, but I’ve managed to create a few unique and interesting images, none-the-less.

For instance, here’s a thumbnail of one I call Solar Flare:

Solar Flare

 

Check out the rest of them here.

And hopefully, I’ll be posting more as time goes on.

McAfee and Word Automation

4
Filed under Installations, Office

Had an issue today where some automation code (basically VB that instantiates Word, Excel, or PowerPoint objects), started failing inexplicably.

The only thing the user could think of is that he’d just installed the lastest McAfee AntiVirus.

So, I tried a little test, opened Excel, opened the VB editor in it, then entered:

Sub Main
   Dim X as object
   Set x = CreateObject("Word.Application")
End sub

And that failed too!

After a few googles, I came up with this.

Appearently, McAfee includes a feature called HAWK (Hostle Activity Watch Kernel), that monitors things like CreateObject.

And the fun part is that even if you disable McAfee, HAWK still runs in the background. You have to turn it off seperately in the McAfee UI.

Yet another reason to use NOD32.

Office 2007 and RibbonIDs

0
Filed under Office, VB Feng Shui

By now, I suspect the Office 2007 Ribbon is a bit old news.

From a developer’s point of view, it’s relatively easy to customize the ribbon via add-in code, which is really nice. And since there seems to be no dearth of examples on doing so, I won’t be wandering down that path.

For Word, Excel, and PowerPoint, things are pretty straightforward, because, as far as I can tell, there’s only one Ribbon for them.

But in Outlook, things are more complicated. The main Outlook window doesn’t even have a ribbon. But the sole parameter of the main entry callback for customizing the ribbon is:

Public function GetCustomUI(ByVal RibbonID as string) as string

so what are the possible RibbonIDs?

After a good bit of searching, I found the following table in the VSTO3CTPTutorial.doc file that identifies them all:

RibbonID MessageClass
Microsoft.Outlook.Mail.Read IPM.Note.*
Microsoft.Outlook.Mail.Compose IPM.Note.*
Microsoft.Outlook.MeetingRequest.Read IPM.Schedule.Meeting.Request or IPM.Schedule.Meeting.Canceled
Microsoft.Outlook.MeetingRequest.Send IPM.Schedule.Meeting.Request
Microsoft.Outlook.Appointment IPM.Appointment.*
Microsoft.Outlook.Contact IPM.Contact.*
Microsoft.Outlook.Journal IPM.Activity.*
Microsoft.Outlook.Task IPM.Task.* and IPM.TaskRequest.*
Microsoft.Outlook.DistributionList IPM.DistList.*
Microsoft.Outlook.Report IPM.Report.*
Microsoft.Outlook.Resend IPM.Resend.*
Microsoft.Outlook.Response.Read IPM.Schedule.Meeting.Resp.*
Microsoft.Outlook.Response.Compose IPM.Schedule.Meeting.Resp.*
Microsoft.Outlook.Response.CounterPropose IPM.Schedule.Meeting.Resp.*
Microsoft.Outlook.RSS IPM.Post.Rss
Microsoft.Outlook.Post.Read IPM.Post.*
Microsoft.Outlook.Post.Compose IPM.Post.*
Microsoft.Outlook.Sharing.Read IPM.Sharing.*
Microsoft.Outlook.Sharing.Compose IPM.Sharing.*

BTW, for those that are interested, in Word, the RibbonID is always Microsoft.Word.Document

Similiarly, in Excel, it’s Microsoft.Excel.Workbook

and in PowerPoint, it’s Microsoft.PowerPoint.Presentation

I wasn’t able to find that info published anywhere. I suppose it’s technically irrelevant, but still…

Solid Writing

0
Filed under Blogging, VB Feng Shui

It’s tough to write well. Unfortunately, too many people out there don’t realize this.

I realize it. I also realize I don’t write particularly well, but recognizing your problem is always the first step, right?

I just came across a Gar’s Tips on Sucks-Less Writing that lays down 10 rules to tighten up your writing. It’s old news, sure, but there’s good stuff there.

In the end, I suppose the most important concept to osmose is to say enough, and nothing more.

Backup Utilities (O the joy!)

0
Filed under Misc, Office

I’m a bit of a toolhound, both of the physical variety (like screwdrivers, bitstops, routers and mitre saws) and of the more ethereal (clipboard loggers and macro recorders). Tools make the fun things even more fun, and the wretched things not quite so onerous.

And one really onerous thing for me is backups. They’re a pain, and it seems it’s always impossible to find what you need when you need it. I’ve got a pile of QIC-60 and QIC-80 tapes that there’s no way I could restore even if I wanted to (note to self, burn them in the next trash fire…)

Anyway, I went on a search some time ago for a decent backup utility. Something free, or close, that was flexible enough for what I needed, simple enough that I’d actually use it, capable enough to make it worthwhile and fast enough to not get in the way.

I believe my search ended with FileBackPC.

It’s a nifty little app that does a nice job of the “copy to a floppy” type of backup. Well, ok, maybe not a floppy these days, but plug in a 500gb USB2.0 removeable harddrive and this app is fantastic.

The good points:

  • It backs up specified directories, with wildcards and all sorts of file filters
  • It can compress and retain a specified number of “previous versions”
  • You can specify sets of folders in “jobs” that can be run independently
  • You can set jobs to automatically run, either on a schedule or on “an event” (like plugging in that USB harddrive!)
  • It can reconnect to other machines on your network and back up files from the (great for small home offices with a server and several workstations or laptops).
  • It can even run batch files and scripts to automatically execute processes before backing up the results of those processes. For instance, I have an item that uses the windows “backup” utility to create a single backup file of the critical system components and my Exchange server data, then I backup that file automatically using FileBackPC.

Off hand, I can’t even think of any bad points, other than it’s not an open source project.

I think my favorite feature is the backup on an event. I set several jobs up to execute when the X: drive comes online (that’s my backup USB drive). So literally all I do now is plug in the USB drive, wait till it finishes the backup, and then unplug it and file it safely away. Slick. And it’s got a nice reporting facility too, that makes it easy to see if there were any problems (open files, read errors, whatever).

And, since it’s a copy style backup, it’s blindingly easy to find that backup file when you need it. Get a couple of USB drives and be doubly safe.

Backup utilities definitely aren’t my favorite things, but they’re something almost everyone with a PC needs. I know this has probably sounded more like an ad than anything else, but it’s not. I’m not getting paid by the FileBack people. This is one of those utilities that I’ve found so handy, useful and easy to work with, that I just felt like mentioning it.