
Since 1998, DevX has helped people start businesses, build websites, and provide enterprise technology to people globally. Interviewing the likes of Microsoft’s co-founder, Steve Ballmer, the publication brings comprehensive, reliable, and accessible insights to the Internet.
You create a routine that uses the Typename() function to find out thetype of an object, and based on that type, performs certain actions. However,when used in a Form object,
Here is a simple way to extract file names from file specifications: Function FName (filespec As String) As String Dim i As Integer Dim size As Integer size = Len(filespec)
Only one copy of a DLL can exist in memory at a time. For this reason, VB doesn’t allow you to create DLLs exposing single use instancing classes. An EXE,
In VB4 you can create a single Splash Screen or About Screen that workswith any program and automatically keeps itself up to date using the newproperties of the App Object.
Microsoft Word exposes the WordBasic object. Through this object, you can execute WordBasic statements. The WordBasic statements and functions can be used as methods of the WordBasic object. Most WordBasic
SQL Server does not return a result set for action queries (SQL insert,update, or delete statements). If you were to use the SQLExecute methodand execute the statement directly, RDO would
One of the greatest features of data-aware controls is that you simplyconnect them to a DataControl and select the fields you need. You havejust created a database program. It can’t
Nulls are still a problem in VB3/VB4-they cause unexpected errors. To handle them, you can read the MDB field into a variant, which can hold a null and then test
I’m programming for a LAN and quite often I add requested features to the program. The LAN is set up so that each workstation is running its own copy of
To build debugging and profiling into your code, add this to the endof code lines: ‘Code line Add this line (n should be replaced’by a unique number)i = j +
I speed up the debugging of applications with queries that return large record sets by using Access 95 to temporarily set the TopValues within the query stored in the MDB.
A VB3 form that has a fixed double border does not show the form’s icon in the upper left-hand corner if you have the control box set to True. Here’s
Use this code to find the binary representation of the currently checked check boxes: Function WhichCheck(ctrl As Object) As _ Integer’ This function returns the binary value ‘ of an
Use this code to find the index of the currently selected control in an array of option buttons: Function WhichOption(Options As _ Object) As Integer’ This function returns the index
The GetRows method retrieves multiple rows of a Recordset (JET) or rdoResultset (RDO) into an array. Ioften use this feature to transfer data between an OLE Server and client applications.
This function returns the difference between two dates on Years, Months, and Days: Function GetAge(dtDOB As Date, _ Optional dtDateTo As Date = 0) _ As String ‘is dtDateto passed
I often have several programming irons in the fire at one time. Jumping back and forth from project toproject, I sometimes lose track of where I left off within each
For consistency’s sake, use this routine wherever your version numbers appear in code: Public Function GetMyVersion() As String ‘ Turn version info into something ‘ like “1.02.0001” Static strMyVer As
When creating resizable forms, I like to place command buttons in either the upper-right or lower-rightcorners. For example, on data entry forms, I place record navigation buttons on the lower-left
In your MDI application, you might have many child forms and need a form to go back to the form thatcalled it. In each child form, declare this variable: Public
VB doesn’t provide a ListRows property, so if you need to display more than eight default items in a combobox drop-down list, use this procedure to increase the size of
Beware of the Val() function. It doesn’t correctly recognize formatted numbers. Use CInt(), CDbl(), and soon instead: FormattedString = Format(1250, _ “General”) ‘ = “1,250.00”Debug.Print Val(FormattedString) ‘ prints 1 !Debug.Print
The Win32 API includes a pair of functions that let you format and copy diskettes from your programs: Private Declare Function SHFormatDrive _ Lib “shell32” (ByVal hwnd As Long, _
If you want to show your users the available memory on the machine, and you’re moving from 16 bits to 32bits, you’ll find the API function GetFreeSystemResources has been dropped.
I wrote a unique error-proof number generator that greatly simplifies the checking of clients’ accountnumbers or other IDs used by your application. I use it in conjunction with the CheckForValid
If you are using the new mail program that can be downloaded for free from Microsoft’s Web site, you can run it from within your program. Simply add this command
You can use the Wingdings font to put simple graphics on a standard command button. Put a standard command button on a form, and in the Properties window, change the
“Hide” an MDI child form with a non-sizable border style (0 or 1) using this code in the MDI child’s Form_Load event: form1.Move form1.Left, form1.Top, 0, 0 Use a label
The API functions “_hwrite” and “_hread” can be useful for writing arrays directly to files and, at some later time, reading these files directly into arrays having the same structure.
Columns in a DBGrid control are bound to database fields. However, the index number of a column doesn’t tell you which field it represents. Therefore, referring to DBGrid1.Columns(0).Value is not