Search Tools Links Login

VB Tech Tips 2


Just some VB Tech Tips, nothing fancy, but informative.

Original Author: Clint LaFever

Code

Take Advantage of Related Documents Area In Project Window


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.




Browse VB Command as You Type


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.




Use the Watch Window to Drill Down into Objects/Collections During Debug


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.




Show the Standard File Properties Dialog


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:


Private Type SHELLEXECUTEINFO

    cbSize as Long

    fMask as Long

    hWnd as Long

    lpVerb as String

    lpFile as String

    lpParameters as String

    lpDirectory as String

    nShow as Long

    hInstApp as Long

    lpIDList as Long

    lpClass as String

    dwHotKey as Long

    hIcon as Long

    hProcess as Long

End Type


Private Declare Function ShellExecuteEX Lib _

    "shell32" (lpSEIAs SHELLEXECUTEINFO) As Long

Private Const SEE_MASK_INVOKELIST=&HC


Private Sub ShowFileProperties(ByVal aFile as
String,h as Long)

    Dim sei as SHELLEXECUTEINFO

    sei.hWnd=h

    sei.lpVerb="properties"

    sei.lpFile=aFile

    sei.fMask=SEE_MASK_INVOKEIDLIST

    sei.cbSize=len(sei)

    ShellExecuteEX sei

End Sub


Please note I typed this directly in here and not in the IDE so there may be
typos.




Start Up in Your Code Folder


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. 




Trick the P&D Wizard


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:


#If False Then

    Private Declare Sub Foo Lib "VIDEO.AVI" ()

#End If


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.


I know this is not really all that useful, but it is a nice trick.



About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 101 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.