Solved

bv forms and modules

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

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…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

810 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