Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

bv forms and modules

Posted on 2004-09-10
1
Medium Priority
?
200 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

721 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