Capturing The Tab Key

This is not an easy task because the TAB does NOT generate the Key_Press event. So, you need to use the GetKeyState windows API function for this. DeclarePrivate Declare Function GetKeyState Lib "User32" (ByVal nVirtKey As Long) As Integer' Virtual key valuesConst VK_TAB = &H9Const VK_SHIFT = &H10 CodeSub txtAreaCode_LostFocus()Dim iRetVal As Integer     ' Check … Continue reading Capturing The Tab Key

Creating A Nested Directory

Even though this code is relatively simple, it's surprising to see the number of major applications on the shelves that fail to correctly handle this scenario. The code shown below consists of two functions. The bValDIR function is needed because in Visual Basic, if you try to create a directory using the MkDir function that … Continue reading Creating A Nested Directory

Create Web Links In Your Program

This is really easy to do. DeclareDeclare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long CodeDim X    X = ShellExecute(hwnd, "Open", "", &O0, &O0, SW_NORMAL)   Tip Submitted By: Ryan Martinsen

Create A Temporary File

The 32-bit API has a call that will create a unique file for you in the Windows temporary directory. DeclareDeclare Function OSGetTempPath& Lib "kernel32" Alias "GetTempPathA" (ByVal BufferLength&, ByVal Result$)Declare Function OSGetTempFilename& Lib "kernel32" Alias "GetTempFileNameA" (ByVal FilePath$, ByVal Prefix$, ByVal wUnique&, ByVal TempFileName$)CodeFunction sGetTempFile(ByRef sPrefix As String)Dim sFilePath As StringDim sTempResult As StringDim lCharCount … Continue reading Create A Temporary File

Compacting An MS Access Database

 The code below can be easily added to a module and even includes code to make a backup (Access is notorious for corrupting databases at a drop of a pin). Compacting large databases can take a long time, so provide your user with a "Please wait..." type message. NOTE: Remember, you cannot compact a database … Continue reading Compacting An MS Access Database

Compacting Memory

You can use the following function to defragment memory, making the maximum available to your program, before beginning any operation that will require a lot of memory. DeclareDeclare Function GlobalCompact Lib "Kernel" (ByVal dwMinFree&) As Long CodeSub CompactMemory ()     Dim R As Long     R = GlobalCompact(&HFFFFFFFF)End Sub UsageCall CompactMemory   This tip is reprinted from … Continue reading Compacting Memory