What's New
Q & A
Tip Jar
Tips & Tricks
These are brief tips and tricks that can make Visual Basic programming easier.
New Control Usage Numerical Stuff
Starting & Stopping I/O Bug Alerts
Software Engineering Printing System Issues
Graphics Coding Techniques Other Programs
Databases Misc Forms


Making Standard Forms

Suppose there is a standard type of form you use a lot. For example, one with a Calendar control in the upper left corner.

To make building this kind of form easier, make an instance of the form set up just as you want it. Position the calendar, set its properties, etc.

Then save the form in the template directory. On my system it's at:

    C:\Program Files\Microsoft Visual Studio\Vb98\Template\Forms
Now when you select Add Form from the Project menu, your form will be one of the choices. When you add this kind of form to your project, it will already have the control on it with its properties set.

About FRX Files

Someone wrote to ask me about FRX files. What are they? How can you edit them? Can you do without them?

Visual Basic stores binary information in the FRX files. For example, if you set a form's Picture property at design time, Visual Basic stores the image in this file. If you delete the file and try to open the project, you get an error and all the information in the file it lost to the project.

I don't know how to edit these files directly. If you replace the form's Picture property at design time, Visual Basic replaces it in the FRX file, but I don't know how to look at the file's contents.

There isn't really any way to do without these files unless you never load binary information like pictures at design time. You could store pictures and other information in a resource file and load it at run time, or you could store this information in separate files (bitmap files, etc.) and load it at run time. This doesn't really give you much benefit, though some would argue that being able to switch resource files at run time is worth it.

These method have the definite disadvantage that they require these files to be there at run time. If you let Visual Basic store the information in FRX files, then it is included in the EXE when you compile the program.

See if a Form is Loaded
You can use the Forms collection to see if a form with a certain name is loaded. Loop through the forms comparing their names to the target name.
    ' Return a form by name if it is loaded.
    Private Function FindForm(ByVal form_name As String) As Form
    Dim i As Integer

        ' Assume we will not find it.
        Set FindForm = Nothing

        ' Search the loaded forms.
        For i = 0 To Forms.Count - 1
            If Forms(i).Name = form_name Then
                ' We found it. Return this form.
                Set FindForm = Forms(i)
                Exit For
            End If
        Next i
    End Function

Forms in the Task Bar
Someone asked why their form did not appear in the task bar. A form should be in the task bar unless any of these is true:
  • ShowInTaskBar is False
  • It's an MDI child form
  • Its BorderStyle is Fixed Dialog
  • Its BorderStyle is Fixed ToolWindow
  • Its BorderStyle is Sizeable ToolWindow

Send your Tips and Tricks to feedback@vb-helper.com.

Subscribe to the VB Helper newsletter
Copyright © 1997-2001 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
www.vb-helper.com/tips14.htm Updated