DeclarePrivate Declare Function MakeSureDirectoryPathExists Lib "IMAGEHLP.DLL" (ByVal DirPath As String) As Long CodePublic Sub CreatePath(ByVal DestPath As String) If Right(DestPath, 1) <> "\" Then DestPath = DestPath & "\" End If If MakeSureDirectoryPathExists(DestPath) = 0 Then MsgBox "Error creating path: " & DestPath End IfEnd Sub Tip Submitted By: Kevin Buchan
Category: VB
Service Pack 6 for Visual Basic 6.0
Service Pack 6 for Visual Basic 6.0 is available as a multi-part download, with a one-file version recommended for broadband users. It includes the latest updates for Visual Basic 6.0 and is advised for all users. More details can be found through the provided link.
Service Pack 6 for Visual Basic 6.0: Run-Time Redistribution Pack
vbrun60sp6.exe is a self-extracting executable that installs the Microsoft Visual Basic run-time files needed for applications developed with Visual Basic 6.0, including updates from Service Pack 6. For more details, visit the Microsoft download page.
Centering The Mouse Pointer Over A Control
The provided code snippet demonstrates how to center the mouse cursor over a control in Visual Basic, regardless of whether it's running on Win32 or other platforms. It includes necessary declarations, a Sub procedure, and usage instructions for calling the function with the control's hWnd property.
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. Declare Private Declare Function GetKeyState Lib "User32" (ByVal nVirtKey As Long) As Integer ' Virtual key valuesConst VK_TAB = &H9Const VK_SHIFT = &H10 Code Sub txtAreaCode_LostFocus() Dim iRetVal … 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 Your Own GUID
Well Visual Basic 5.0 comes with a program that create them for you, but what a pain. Wouldn't it be nice to just do it via code? Well now you can with the sample code below. DeclareType GUID Data1 As Long Data2 As Integer Data3 As Integer Data4(7) As ByteEnd Type Private Declare Function CoCreateGuid Lib … Continue reading Create Your Own GUID
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", "http://www.microsoft.com/vbasic", &O0, &O0, SW_NORMAL) Tip Submitted By: Ryan Martinsen
Create A Temporary File
The 32-bit API provides functions to create unique temporary files in the Windows temporary directory. The code defines a function that generates a temporary file with a user-defined prefix. Users must manually manage and delete these files, as Windows won't automatically remove them upon application closure.
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

You must be logged in to post a comment.