Here's a quicker way of making sure you get at least a two-digit number:
tex$ = Format$(num, "00")
If you would prefer to pass in the number of digits to pad to then this will do it:
tex$ = Format$(num, String$(Digits, "0"))
Where "Digits" is an integer variable specifying the number of digits to pad to.
This should be marginally faster:
Set Picture1.Picture = Nothing
It's possible that tex$ can be more than 2 characters long (in your original code and in my versions above) so it's probably best to
pass in Len(tex$) as the last parameter of TextOut() (and in GetTextExtentPoint32()) unless you're validating it elsewhere.
If you grab the latest version of the OLEPicture library from my site, it will perform the cleanup for you to cut down the amount
your code has to do. There's also an icon library which was derived from my original post to you which you may find handy.
I've not tested it, but the rest looks ok to me - Check though that you've got no GDI resource leaks when creating a bunch of
different icons, icons are notorious for leaking their internal bitmaps if you're not careful.
Hope this helps,
- Microsoft Visual Basic MVP -