
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.
Use this as a fast way to paint the background of any form witha really cool “fading” color (lighter at top to darkerat bottom). To specify base color, pass True/False
This syntax is much faster than using an If.Then.Else construct to detectnull or zero-length fields, and it will ensure that an error will not occur.For strings: Dim sVar As String.sVar
I use this procedure to center my forms. With frmParent, the lastloaded form is centered against the parent form. Otherwise, it’scentered against the screen. I always center forms in the
Use the SendKeys function to exploit the delete functionalityof many grid and spreadsheet controls that have a delete functionality.Use this functionality without writing code to delete each rowif your form
Whenever you use For.Next loops, it is faster NOT to use the countername after Next (of the For.Next loop). In nested loops, it produces significantlyfaster code. Sub Form_Load ()Dim TStart!Dim
You can use relative references to specify file paths in your MAK file.For example: Path=”..SETUPDISK1.” When you use relative references,you can move entire directory structures in File Manager without havingto
A while back, I wrote a simple orders application that allowedusers to query and update order information. The application workedfine, but lacked a user activity log. It was difficult for
When you first start using the VB database functions, you might wonderwhy they call its engine JET–it seems to not fly. Using databasetransactions (search the online help for BeginTrans) might
Look for a thin horizontal line at the top of the client area in theVB code window that comes up when you view code for a form or a module.If
You do not have to use the return value of any function! Thisnew behavior is in the manual (under CALL), but is a shocker,and a little dangerous: Private Sub Form_Load()
“Send a Message” (Windows Programming, by Jonathan Zuck,VBPJ December 1995), a great example of code usable ina text editor, mentions three ways to code the Clipboard functionsusing SendMessage, VB’s Clipboard
To stop the selection bar on a data-bound grid from moving when navigating through records in the boundRDC or the rows on the grid, use the API call LockWindowUpdate(gridname.hwnd) before
By default, VB list boxes use any keyboard input to find the firstitem beginning with the pressed letter. Where the number of itemsin a list box is large (>100), this
This subroutine shows how byte arrays can speed a search though a file.The routine is called with the file name, a string to look for, a flagthat tells it to
Running applications written in VB3 in the WIN95 OS is not always aclean conversion. This code would work fine in Windows for Workgroups 3.11,but would GPF in WIN95. SS3D2.VBX, which
When loading a form, reduce the “flicker” and “flash” of the GUI by using these Windows API functions: ‘Declarations Section#If Win32 Then Declare Function LockWindowUpdate _ Lib “user32” _ (ByVal
Optional parameters are a great new feature in VB4, but the ParamArraykeyword is an overlooked addition to function and subroutine declarations.The ParamArray keyword allows an unspecified number of Variantparameters to
To have a program programmatically close another program, use this code: ‘ Close an existing program Title = “VBApp” ihWnd = FindWindow(0&, Title) ihTask = GetWindowTask(ihWnd) iRet = PostAppMessage(ihTask, WM_QUIT,
When a control is deleted from a form, any code behind that controlis not deleted. It still exists in the code in the General area. Such strandedcode might not be
Designing monitor resolution-independent applications is a frequentproblem Visual Basic programmers face. The simplest solution isto design forms at the 640 by 480 resolution found in most lap-topcomputers. Such a form
The DegreesToXYsubroutine, part of CodeBank’s standard procedurelibrary, calculates the X (horizontal) and Y (vertical) coordinatesof any point, measured in degrees, on the circumference of a circleor ellipse. As you can
You cannot use the IsEmpty function to determine if a variableof type Form or any Object has been assigned a value. You can,however, use this method to determine if the
When you’re finished tinkering with your apps, close and restart VBbefore making the final EXE. This simple action can reduce the size ofyour EXE by 10 to 30 percent (many
You cannot load a VB4 form in VB3 directly. You must modify theform definition. When you open a VB4 form, the file will resemblethe example: VERSION 4.00Begin VB.Form Form1 Caption
Programmers are in the habit of creating meaningful identifiersby concatenating the words of a “title case” phrasethat describes the identifier, such as LastName or FinalPaymentDate.Often, you can use these names
I needed a way to issue a DoEvents to allow Windows time to redraw controlson a form, but wanted to prevent the user from clicking some other controlwithin my application.
In many cases, it is best to select or highlight the full text of afield when that field gains the focus. This allows the user to simply begintyping to replace
When using the SQL Server ODBC driver and SQL Server, and If ODBC preparedexecution is used, certain floating-point values may be incorrectly converted.Microsoft Access and Microsoft Visual Basic commonly use
One way to test whether a specific file exists is to open thefile for input and check VB’s error flag. An error will occurif the file does not exist. Use
Never, never, never assume that a given API call or control/OCXworks the same under Win95 and Windows NT. For example, the 32-bitfile common dialog handles long file names, right? Well,