Solved

bv forms and modules

Posted on 2004-09-10
1
193 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now