June 12, 1999

Compound member attributes

The Procedure Attributes dialog includes a Procedure ID combo box, that lets you associate a particular ID to a given member of the class. You usually use this combo to make a property or a method the default item of a class or an ActiveX control, but there are other

Retrieve the currency symbol

It is very simple to retrieve the correct currency symbol, using just plain VBA statements: currSymbol = Trim$(Replace(FormatCurrency(0,0), “0”, “”)) If you can also determine if the symbol precedes or follows the currency amount using this method: If Instr(FormatCurrency(0,0), currSymbol) < Instr(FormatCurrency(0,0), "0") Then ' Currency symbol precedes the currency

Never mix SingleUse and MultiUse classes

ActiveX components written in VB can contain both SingleUse and MultiUse classes at the same time. It usually isn’t a good idea to use both types of classes in the same project, however.When a client creates an instance of a SingleUse class, COM always runs a new instance of the

Caveats of the CopyMemory API function

Here’s the correct declaration of the CopyMemory API function, which is so useful whenever you want to move a block of bytes between two memory locations: Declare Sub CopyMemory Lib “kernel32” Alias “RtlMoveMemory” (dest As Any, _ source As Any, ByVal bytes As Long) You should be aware of a

Always ensure that a printer is installed

Many developers incorrectly assume that a printer is always installed on their customers’ machines, and therefore omit to check that this is actually the case. The following function, deceiptively trivial, returns False and displays an error message if no printer has been installed: Function PrinterIsInstalled() As Boolean Dim dummy As

Retrieving Bitmap properties

The Picture box control does not directly expose any property that returns information on the bitmap currently loaded. You can retrieve this information by calling the GetObject API function, passing it the handle of the bitmap. This value is the Handle property of the IPictureDisp object (which is also the

ShowPrinterProperties – Display printer’s Properties dialog

Private Declare Function PrinterProperties Lib “winspool.drv” (ByVal hwnd As _ Long, ByVal hPrinter As Long) As LongPrivate Declare Function OpenPrinter Lib “winspool.drv” Alias “OpenPrinterA” _ (ByVal pPrinterName As String, phPrinter As Long, _ pDefault As PRINTER_DEFAULTS) As LongPrivate Declare Function ClosePrinter Lib “winspool.drv” (ByVal hPrinter As _ Long) As LongPrivate

Tricks with LCase and UCase

There are a few tricks that you can do with LCase$ and UCase$ functions. I doubt you will be using this tip in all your applications, but here they are for when you’ll need them. Say you wish to check that a string (or a portion of it) does NOT

GetFilePath – Extract the path portion of a file name

‘ Retrieve a file’s path” Note: trailing backslashes are never included in the resultFunction GetFilePath(FileName As String) As String Dim i As Long For i = Len(FileName) To 1 Step -1 Select Case Mid$(FileName, i, 1) Case “:” ‘ colons are always included in the result GetFilePath = Left$(FileName, i)

No more posts to show