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
Category: VB
Automating A Settings Dialog Form
During the development of your project, the types and number of settings can grow and grow. With these routines, you can write the code once, then you usually won't need to update this code even when you add new controls. For each setting that you save, whether to the Registry or an INI, you'll need … Continue reading Automating A Settings Dialog Form
Automatic Selection Of Text In VB4
I have developed a global subroutine that will highlight the text of the active control of the active form. The routine is simple:Sub Highlight() On Error Resume Next Dim FRM1 As Form Set FRM1 = Screen.ActiveForm FRM1.ActiveControl.SelStart = 0 FRM1.ActiveControl.SelLength = Len(FRM1.ActiveControl)End Sub Create a form object by first dimensioning it and setting it to … Continue reading Automatic Selection Of Text In VB4
Centering A Form
If you use a higher screen resolution than your users, your forms could be partially hidden or even completely off the screen. There are a few different ways to center your Forms and this tip is by far the best one. It’s very useful because you can center your form over any other form. … Continue reading Centering A Form
GetTickCount API Routine Is Faster Than Timer
The Timer's "roll-over" point is 24 hours. Since Timer only returns seconds, using GetTickCount also gives you a much higher resolution. DeclareDeclare Function GetTickCount Lib "User"() As Long UsageDim lTimer1 as LonglTimer1 = GetTickCount() This tip is reprinted from the VB Tips & Tricks Volume 1 book. Compatible With: Visual Basic 3.0, Visual Basic … Continue reading GetTickCount API Routine Is Faster Than Timer
File Copy With Version Checking
xFile - The filename (it copies from the application's own directory) xDest - The destination directory DeclareDeclare Function GetVersion Lib "Kernel" () As LongDeclare Function GetFileVersionInfo% Lib "VER.DLL" (ByVal lpszFileName$, ByVal handle As Any, ByVal cbBuf&, ByVal lpvData$) CodeSub CheckFile(xFile As String, xDest As String)On Error Resume NextDim retS%Dim retD% If Right(xDest, 1) <> "\" … Continue reading File Copy With Version Checking
Enter Key Wreaks Havoc when Exporting Databases to Text Files
This value gets passed between the database and the application effortlessly. The problem arises when inevitably you want to export the tables into a flat file. It exports just fine except that the Chr$(13) & Chr$(10) get converted back to the effects of an enter keystroke and cause your export file to be out of … Continue reading Enter Key Wreaks Havoc when Exporting Databases to Text Files
Dealing with Null Database Fields
The best way to deal with this problem is to use the built-in & operator to concatenate a blank string to each field as you read it. Concatenate 0 for numeric fields. Sample CodeDim dbBiblio As DatabaseDim rsData As RecordsetDim sYear As StringDim sHireDate As DateDim lReports As Long Set dbBiblio = OpenDatabase("Northwind.mdb") Set rsData … Continue reading Dealing with Null Database Fields
Create Unique Temporary File Names
Although only one function is presented here, you may notice a gold mine of other associated and required functions that may be used for a multitude of purposes. CodePublic Function GetUniqueFileName(ThisEXT As String, Optional ThisPath As String) As String Dim retval As String, varTmp As String varTmp = NormalizePath(GetTEMPdir(True)) Do If LTrim(RTrim(ThisPath)) <> "" Then … Continue reading Create Unique Temporary File Names
Copying Rows In Access
Supposedly, RecordCount is set correctly when you first open a snapshot, but the ListBox test showed otherwise. Try it yourself. Here is the solution code with my debug lines commented out.Sub CopyRows () Dim i As Integer Dim db As Database Dim snap As Snapshot Dim tbl As Table Dim wSQL As String Set … Continue reading Copying Rows In Access

You must be logged in to post a comment.