
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 can add ‘Type Ahead’ functionality to the standard VB ComboBoxcontrol with this subroutine: Sub ComboTypeAhead(Combo As ComboBox)Dim i As Integer, _ KeyString As String, _ KeyLen As IntegerKeyString =3D
In order for a label to be associated with a control (such as a textbox) for using hot keys, they must be in TabOrder sequence, the label beingone more than
If the layout of VB4’s DBGrid is not changed at design time, it willautomatically configure to a new record set when the Data control is refreshedwith a new RecordSource.
Shut down the instance of Visual Basic that uses the compiled in-processOLE server to unload the server from memory. Changes to the in-processOLE server will not be seen until the
When using DDE Links at design time, the link will be temporarily cutwhen the program is run. Some, but not all, programs will reestablish theconnection.
If Crystal Reports’ speed is lacking although your report contains nolarge graphics or large numbers of groups, change these two lines in yourCRW.INI file to solve disk swapping problems: MaxRecordMemory=0MetapageSpillLimit=100
Use the Microsoft Developer Network to search for errors that seem to defy explanation. VB4 comes with a short version of the MSDN, and subscriptions are available through Microsoft.
Note that some key combinations are different from those for VB 3.0:Ctrl-T–Custom Controls. Ctrl-E–Menu Editor. Ctrl-F–Find (Unchanged from VB3). Ctrl-H–Replace (H? Yes, H! Go Figure!).
Use the OLE Restrictions option to test the in-process OLE server asan out-of-process server. The OLE DLL Restrictions option is in the Advancedtab of the Options dialog box. This option
The Printer object’s EndDoc method resets the FontName property. Ifyou want your application to print separate documents, invoking EndDocat the end of each, set the FontName before printing the first
Don’t return references to Form and Control objects from your OLE server.Rather, provide wrappers for the properties and methods of forms and controlsif they must be manipulated by your OLE
Use this code to cause a TextBox control to automatically scroll down as you concatenate new text: ””Select the end of the text MyTextBox.SelStart = Len(MyTextBox.Text)””Put the new text thereMyTextBox.SelText
Instead of declaring an object As Object, use the specific object type, such as CTask. This improves performance by minimizing the OLE lookup requirements.
Use an ampersand (&) instead of a plus sign (+) when concatenatingstrings. Depending on the data type of the operands, using the plus signmay result in an addition.
Don’t use any objects in the Visual Basic object library as parametersor return values for exposed properties or methods in public classes. Theseobjects are not intended to be used from
Use With…End With to minimize the number of repeated OLE lookups.This has the added advantage of not requiring the temporary substitutionobject.
Place one label on your form, tailor its properties (such as left-alignand autosize), and copy and paste it to create the rest of your labels.
Start the in-process OLE server using a Sub Main procedure. Includeall server initialization code in the Sub Main procedure. Don’t show formsfrom the Sub Main procedure and don’t use the
VB developers that program with C language might be confused by a feature in the language. Consider thiscode: Dim x As IntegerDim y As IntegerDim z As Integer x =
Do set all object variables to nothing before ending the application.When the End statement is executed in the OLE client application, the OLEserver is shut down and the Terminate events
Don’t display errors from the OLE server. Instead, raise an error tothe client application. Use error numbers greater than vbObjectError +512 and less than vbObjectError + 5535. Values between vbObjectError
Often when using Transact-SQL, I want to capture comments from a user in a text box and send them tothe database. However, if the user types an apostrophe in the
I design VB applications for approximately 300 employees in a networked environment. It’s difficult to keepthose PCs up to date with the most current version of an app, so I
Use this algorithm to swap two integer variables: a = a Xor b b = a Xor b a = a Xor b
Place this code in the declaration section of a module: Public Sub Win95Shrivel(xForm As Form) ‘ Sets the form’s window status to ‘ minimized xForm.WindowState = 1End Sub Call it
When an image list is referenced by another object such as a toolbar, you can only add images to the imagelist. VB doesn’t allow deletes or changes to the size
I was developing a CGI application that read a database and pieced together the fields into a string forrepresentation as an HTML form. The surprise came when I found how
Code portability is extremely important, especially now that VBA is available in so many products. Someproblems might occur if you want to use VB4 or VB5 code in Access 8
Document the interface for your OLE server by using the Options buttonin the Object Browser. To provide more full-featured documentation, usea help file. Use the Object Browser to tie the
Pass as much data to and from the OLE server as possible in each call.Data transfer is fast, but calling is slow, especially with out-of-processservers. For example, you could pass