Solved

bv forms and modules

Posted on 2004-09-10
1
196 Views
Last Modified: 2010-04-24
I am creating a form with tabs.  It is a nice concept but the problem is I am finding the form becoming very monolithic.

Is there a way to modulize the form better so I can organize my functions.

What I want to do is make modules for error checking so before the client can submit the information in the controls can be validated .  How can i do this

for example I was trying to do this in a module

public sub clientFormPageErrorCheck()

if txtClientID.Text.equals("") and txtFamilyNumber.text.equals("") then

throw new system.exception("Client ID or Family number must be entered.")

end sub


it will work in the form but not in the module
0
Comment
Question by:genesisproject
1 Comment
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 12027875
The easiest solution would be to leave all the code in the form and define Regions in it so you can collapse them when you don't want to see them.  You create the regions by simply typing #Region "Your desired region name here" and then ending it with #End Region as shown below:

#Region "Validation"

    Private Sub foo()

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

    End Sub

#End Region

If you want to move some of the code to a module, then you can pass in a reference to the form so it can access the controls on it:

    public sub clientFormPageErrorCheck(byval f as form1) ' or whatever your form name is....

        if f.txtClientID.Text.equals("") and f.txtFamilyNumber.text.equals("") then

            throw new system.exception("Client ID or Family number must be entered.")

    end sub

From your form you would call it like this:

    clientFormPageErrorCheck(Me)

Regards,

Idle_Mind
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question