Visual Basic

Cache Properties for Repeated References

If you have to reference a control’s property repeatedly, it’s better to assign the property to a temporary variable, then use that variable. This technique is called property caching. For example, if you need to assign text value in the Text1 textbox to all elements in an array named arr,

Extract Red,Green,Blue components of a color

If you have a 32-bit color value in RGB format, you can extract its Red, Green and Blue components using the following routines: Function GetRed(ByVal lColor As Long) As Long GetRed = lColor Mod 256End FunctionFunction GetGreen(ByVal lColor As Long) As Long GetGreen = (lColor &H100) Mod 256End FunctionFunction GetBlue(ByVal

Display Contents of ADODB.Errors Collection

When ADO encounters an error, the Errors Collectionis filled with certain specific details on the causeof the error. You can check the Errors collection ofthe Connection object whenever you encounter an errorFrom an ADO object.Here is a simple method which can be used to displaythe errors collection of Connection Object.

Perform Faster String Manipulations

Are you dealing with strings you have to parse if you want to drop one special character or change it into another? Keep this trick in mind. Even though this code seems to work fine, there is one minor problem that can cause headaches. The time you spend in memory

Registering COM Components (*.dll) and Type Libraries (*.tlb)

In order to run this tech tip you need following things:(a) VB5 or VB6(b) Reference to Type Lib information object component (TLIBINF32.dll). This function takes in the name of the com component (or dll) or the typelibrary which needs to be registered. Private Function RegisterTypeLib(ByVal strTypeLibName As String) As Boolean

Link List Contents to Listindex in Another List

I recently needed to create two listboxes, where the items displayed in the second listbox depend upon the item selected in the first listbox. After seeing the amount of code it took to do this using standard arrays, I came up with a better solution using array functions that reduced

Create Better Button Arrows

Many times developers use a form’s default font arrow characters for To and From buttons between listboxes. To give your app a nicer, more solid look, do what Microsoft does-use the Marlett font, which is added by default to all Windows 95, 98, and NT4 and later installations. Instead of

HiWord – The most significant word in a Long value

Private Declare Sub CopyMemory Lib “kernel32” Alias “RtlMoveMemory” (dest As _ Any, source As Any, ByVal bytes As Long)’ Return the high word of a Long value.Function HiWord(ByVal value As Long) As Integer CopyMemory HiWord, ByVal VarPtr(value) + 2, 2End Function

No more posts to show