Solved

bv forms and modules

Posted on 2004-09-10
1
199 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 86

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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

623 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