VB Tech Tips 2
Just some VB Tech Tips, nothing fancy, but informative.
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
<p><b><small><font face="Verdana">Take Advantage of Related Documents Area In Project Window</font></small></b></p> <p><small><font face="Verdana">If you use a resource file in your application, you can see the RES file appear in the project window under "Related Documents." This is the only type of file that VB automatically adds to this node of the project tree. You can add any type of file you like to this area manually, though. From the Project menu, selected Add File, or right click on the project window and select Add File from the context menu. In the dialog box, select All Files for the file type and check the Add As Related Document option. Adding additional related files here helps organize your project and gives you quick access to useful items, including design documents, databases, resource scripts, help project files, and so on. Once a file has been added, double-click on it in the project window to open it with the appropriate application.</font></small></p> <hr> <p><small><b><font face="Verdana">Browse VB Command as You Type</font></b></small></p> <p><small><font face="Verdana">When you refer to an object in VB, you get a dropdown list of that object's properties and methods. But, did you know that the statements and functions of the VB language can be pulled up in the same way. You can view the list as you type in one of two ways. One (which just shows how it all works) is to type VBA. then the list will appear. There you can see the list off all VB functions and have it filter down as you type. The quicker way is to just press CTRL+SPACE prior to typing your VB function/command. i.e.; On a blank line press CTRL+SPACE then type ms At this point it should be at MsgBox. While yes most commands are short enough that the CTRL+SPACE does not really save you any time, but one you will not having any typos and two, it will help you remember/find a call that you do not use much.</font></small></p> <hr> <p><small><b><font face="Verdana">Use the Watch Window to Drill Down into Objects/Collections During Debug</font></b></small></p> <p><small><font face="Verdana">All of know about the immediate window, but I find very few developers who know of the Watch Window. The watch window is a very nice tool to drill down any any variable whether it is a standard type or an object or a collection. For an example, open on of your database project where you open a recordset. Set a break point after you open your recordset. Run your code. When you hit your break point, highlight your recordset variable right there on that line (double click on it too for quicker highlighting). Now right click your highlighted variable and choose Add Watch. On then next window click Ok. Presto your recordset variable show now be displayed in the Watch Window. You can expand it out and drill down to all the properties within. Not only is this a good tool to use to inspect your objects and collections at runtime, but also a good teaching tool to help those trying to understand objects and how they are constructed.</font></small></p> <hr> <p><small><b><font face="Verdana">Show the Standard File Properties Dialog</font></b></small></p> <p><small><font face="Verdana">If your program has an Explorer shell-style interface, you probably want to supply the standard File/Properties dialog. Do this by using the ShellExecuteEX API function:</font></small></p> <p><small><font face="Courier New">Private Type SHELLEXECUTEINFO<br> cbSize as Long<br> fMask as Long<br> hWnd as Long<br> lpVerb as String<br> lpFile as String<br> lpParameters as String<br> lpDirectory as String<br> nShow as Long<br> hInstApp as Long<br> lpIDList as Long<br> lpClass as String<br> dwHotKey as Long<br> hIcon as Long<br> hProcess as Long<br> End Type</font></small></p> <p><small><font face="Courier New">Private Declare Function ShellExecuteEX Lib _<br> "shell32" (lpSEIAs SHELLEXECUTEINFO) As Long<br> Private Const SEE_MASK_INVOKELIST=&HC</font></small></p> <p><small><font face="Courier New">Private Sub ShowFileProperties(ByVal aFile as String,h as Long)<br> Dim sei as SHELLEXECUTEINFO<br> sei.hWnd=h<br> sei.lpVerb="properties"<br> sei.lpFile=aFile<br> sei.fMask=SEE_MASK_INVOKEIDLIST<br> sei.cbSize=len(sei)<br> ShellExecuteEX sei<br> End Sub</font></small></p> <p><small><font face="Verdana">Please note I typed this directly in here and not in the IDE so there may be typos.</font></small></p> <hr> <p><small><b><font face="Verdana">Start Up in Your Code Folder</font></b></small></p> <p><small><font face="Verdana">For the shortcut you use to open VB, change the Start In in the Properties of the shortcut to point to the folder you prefer to have as the default Open and Save to start at. </font></small> </p> <hr> <p><small><b><font face="Verdana">Trick the P&D Wizard</font></b></small></p> <p><small><font face="Verdana">Do you have external files to your application that you want to make sure are always included with your application when you go and create a new setup for it. Just use this little trick:</font></small></p> <p><small><font face="Courier New">#If False Then<br> Private Declare Sub Foo Lib "VIDEO.AVI" ()<br> #End If</font></small></p> <p><small><font face="Verdana">VB will ignore this statement but the P&D Wizard will not. The P&D Wizard will pick up this line and also remember to add this file to the list of files required for your application.</font></small></p> <p><small><font face="Verdana">I know this is not really all that useful, but it is a nice trick.</font></small></p> <hr>
Original Comments (3)
Recovered from Wayback Machine