473,216 Members | 1,507 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,216 software developers and data experts.

Constructor and RaiseEvent for validation

Hello

I am switching my courses from VB 6 to VB.Net. I teach my students to place validation inside the class. If data is invalid, then I want to raise an event in the form. This works fine when done from the Set property of a data member. I want to code a parameterized constructor so the user of the class can set initial values. I placed data validation in the constructor but it will not raise the event from the constructor. I tried creating a separate routine, say ValidateName and firing the event from there. This procedure works when it is called from the Set property. It does not work when it is called from the constructor.

If what I want to do is not possible, then what is the standard way of handling this? I teach my students not to use a messagebox or a form control inside the class because the class should be reusable. Also, I want to user of the class to handle invalid data as they see fit and raising an event solves that

Thanks in advance
Jani

Nov 20 '05 #1
1 2748
* "=?Utf-8?B?SmFuaXNLQg==?=" <an*******@discussions.microsoft.com> scripsit:
I am switching my courses from VB 6 to VB.Net. I teach my students to
place validation inside the class. If data is invalid, then I want to
raise an event in the form. This works fine when done from the Set
property of a data member. I want to code a parameterized constructor so
the user of the class can set initial values. I placed data validation
in the constructor but it will not raise the event from the constructor.
When the ctor code executes, event handlers are not already added.
If what I want to do is not possible, then what is the standard way of
handling this?


Throw an exception or something like that.

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Guille | last post by:
Hi all! I'm having some weird behaviour in a .NET application i'm developing. I'll try to explain: I've created a Class that wraps an asynchronous socket. When connect callback is called, i...
8
by: Nicolas | last post by:
How do I do a RaiseEvent in csharp I'm ok in VB but csharp confused me a lot. ******* code ******** private FileSystemWatcher watcher = new FileSystemWatcher(); public delegate void...
2
by: Carl tam | last post by:
Hi everyone, I got a quite interesting problem myself and got stuck. I have an aspx page with a windows user control with it. in the Windows Control. I have a RaiseEvent statement, say...
2
by: Lim | last post by:
I've developed a program that raise an event. This program works fine on a Windows 2000 Professional PC. However when I try to run the program on a Windos XP Professional PC, the program will not...
2
by: dmoonme | last post by:
I'm trying to rename some files in a directory. Pretty basic stuff - renaming the files works fine but the problem I have is updated the text in textbox. All I want to do is appendtext to a...
7
by: Onokiyo | last post by:
Hello, I have the code below and somehow the message from RaiseEvent doesn't pop up at all. Can someone help me please? '------CODE '------/form1.vb/VB2005/Framework20--------- Imports...
3
by: Steven Blair | last post by:
I have encountered this problem a few times and would like to see how other people deal with it. A library has a Constructor that takes in n params and does some basic validation and populates...
1
by: Terry Olsen | last post by:
I have a program with a couple of long running processes that i'm calling on a separate thread. When the process is completed, I want to raise an event to tell the main thread that it's done. I...
2
by: ffa | last post by:
I have a number of classes that declare a public Event called RefreshData: Public Class Client Implements INotifyPropertyChanged Implements IDisposable Implements IDataErrorInfo Public...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.