This month's column continues with a look at some of the different and interesting aspects of the Visual Basic language, all presented together under the general title of "Did You Know?". A quick way of changing properties One of Visual Basic's strengths is undoubtedly its use of properties to alter the behaviour and appearance of Windows' objects. However, it can be slightly annoying, not to mention time consuming, when you want to change the same property on a largish number of controls on a form. For example, you might have a dozen TextBoxes on a form which are to be invisible when your program first executes. In design mode, rather than setting the Visible property of each TextBox individually, do the following instead. Left-click the first TextBox using your mouse, and then, while holding down the Ctrl key on the keyboard, left-click all of the remaining TextBoxes. As you click each one, you'll notice that its border will change colour. Once you've clicked all the TextBoxes, press the F4 key. This will cause the Property window to open and display. Now to set the Visible property, simply double-click its caption in the Property window to toggle between the possible values of True and False. Try this procedure again, but this time click on a TextBox and a command button on a form instead. Even though these two types of control have their own unique properties, this Ctrl key method still allows you to change those properties quickly, like the Visible property, which are common to both controls. Bookmark your VB code As your Visual Basic programs become more complex, they inevitably grow larger in size, too. This increase in the number of lines of code can sometimes make it frustrating to find particular sections of code quickly. However, Visual Basic 5.0 easily solves the problem with its use of "bookmarks", just one of the new functions of the Code Editor. As its name suggests, this feature allows a nominated line of code to be associated with a bookmark for quick reference. Multiple bookmarks can be set up for any project. To see how bookmarks work, open the code window of any Visual Basic program, and select a line of code by left clicking it with the mouse. Next, click "Edit" on the main VB design menu, and scroll down until the mouse cursor is over the last entry, "Bookmarks". From the subsequent cascading menu, click "Toggle Bookmark". The selected line of code is now identified as a bookmark by a coloured indicator displayed in the left hand margin of the code window. It's easy to remove a bookmark. Simply select the line of code which has been designated as a bookmark, and follow the procedure outlined above to toggle it off. However, a quicker, more convenient way of toggling bookmarks on and off is to right click a selected line of code using your mouse, and then to click the "Toggle" and "Bookmark" options from the subsequent menus (see Figure 1). Note also how the "Toggle" option can be used to set breakpoints on and off as well. Once a number of bookmarks have been inserted into the code, it's then possible to move backwards and forwards between them using the "Next Bookmark" and "Previous Bookmark" on the "Bookmarks" option of the "Edit menu". From there, it's also possible to clear all bookmarks with a single click of your mouse using "Clear All Bookmarks".
Designing forms quickly |