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
This is a multi-part download of Service Pack 6 for Visual Basic 6.0. Customers with broadband connections are encouraged to download the one-file version. See the Related Resources link. Service Pack 6 for Visual Basic 6.0 provides the latest updates to Visual Basic 6.0. It is recommended for all users of Visual Basic 6.0. … Continue reading Service Pack 6 for Visual Basic 6.0
Service Pack 6 for Visual Basic 6.0: Run-Time Redistribution Pack
vbrun60sp6.exe is a self-extracting executable file that installs versions of the Microsoft Visual Basic run-time files required by all applications created with Visual Basic 6.0. The files include the fixes shipped with Service Pack 6 for Visual Basic 6.0. http://www.microsoft.com/downloads/details.aspx?familyid=7b9ba261-7a9c-43e7-9117-f673077ffb3c&displaylang=en
Centering The Mouse Pointer Over A Control
Positioning the cursor over the button they will are likely to make the action quicker and easier. The following code will center the mouse cursor over any control that has an hWnd property. Declare#If Win32 Then Type RECT left As Long top As Long right As Long bottom As Long End Type Declare Sub GetWindowRect … Continue reading Centering The Mouse Pointer Over A Control
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 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 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

You must be logged in to post a comment.