August 8, 1998

Set Printer Margins

You can use the Printer’s scale properties to set margins. Set the properties so the position (0, 0) is mapped to where you want the margins. This code makes the left margin 0.5 inch and the top margin 0.75 inch. The factor of 1440 converts inches into twips: Printer.ScaleLeft =

Make a Form Stay on Top

You can make a form always remain above others, even when it does not have focus. Use this code in a BAS module: #If Win16 Then Declare Sub SetWindowPos Lib “User” ( _ ByVal hWnd As Integer, _ ByVal hWndInsertAfter As Integer, _ ByVal X As Integer, ByVal Y As

Perform One-Time Initialization

You can use static variables to perform one-time initialization: Private Sub GetValue()Static initialized As Boolean If Not initialized Then ‘ Perform one-time initialization. : initialized = True End If ‘ Do other stuff. :End Sub

Convert an Array Into a String in JavaScript

If you want to convert an array into a sting, the join method is your best bet. This method takes one parameter and uses it as the separator between each array element as it is added to the string. Although spaces, commas, and dashes are common separators, you can forego

Use Explicit Object Types for Speed

It is much faster to use explicit object data types instead of generic ones. In this test that simply sets an object’s public variable, the generic object takes more than 150 times longer than the specific object: Private Sub Command1_Click()Dim specific As MyClassDim generic As ObjectDim start_time As SingleDim stop_time

Create Global Properties

You can create property procedures in a BAS module. The rest of your program treats the “property” like any other variable, but the property procedures can perform error checking and one-time initialization.

Error ‘ASP 0115’

If you are developing in Visual Basic for Active Server Pages (ASP), there are two likely causes of an error ‘ASP 0115’. The VB5 setup wizard puts a number of DLLs into the /System32 directory without checking whether versions of these DLLs exist elsewhere on the computer, which results in

Hidden IP Address

One of the easiest ways to grab an IP address is to use request.servervariables(“REMOTE_ADDR”) and then store the value as a hidden field in your form. When the user submits the form, you can write the field containing the IP address directly into your database along with the other fields.

Creating Instance of InetAddress

InetAddress objects can be instantiated only by doing a hostname or address lookup by calling any one of the static lookup methods in the InetAddress. For example, to create an InetAddress object that represents the address of the Web site (, you would write the this code: InetAddress inquiry;try

No more posts to show