devxlogo

Tip Bank

Load a text file in one operation

The fastest way to read a text file is using the Input$ function, as shown in this reusable procedure: Function FileText (filename$) As String Dim handle As Integer handle =

Multiple compilation constants

Visual Basic’s documentation does not explain how to specify more than just one conditional compilation constant in the Advanced tab of the Options dialog. The correct way is using a

SystemDirectory – The path of the System directory

Private Declare Function GetSystemDirectory Lib “kernel32” Alias _ “GetSystemDirectoryA” (ByVal lpBuffer As String, _ ByVal nSize As Long) As Long ‘ The path of the System directoryFunction SystemDirectory() As String

Convert Hexadecimal numbers

While Visual Basic offers the Hex$ function that converts a decimal value into its hexadecimal equivalent number, it seems that the inverse function is missing. Not true. Try out this

Storing objects in the Tag property

The Tag property exposed by many Windows Common Controls (including TreeView’s Node objects and ListView’s ListItem objects) is more versatile than the ListBox and ComboBox controls’ ItemData property, because it

Caution when moving or resizing forms

Any action that affects a form’s size or position should be inhibited when the form is minimized or maximized, because this causes a runtime error 384. Always double check your

Determine how a control got the focus

At times it might be convenient to know how a given control got the focus, namely by means of the Tab key, an associated hotkey or a click of the

Properties of Static Storage

Global objects, static data members of a class, namespace variables, and static variables in functions reside in static memory. Static objects are allocated by the linker and their address remains