473,396 Members | 1,924 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,396 software developers and data experts.

stop creation

Hello,
I have as class and when I get wrong data when creating the object (in the
'new' routine) I want to break off the creation of the classObject, so it
results in 'nothing' to the creator . How can I do that?
Thanx
Frank
Nov 20 '05 #1
3 1068
"Frank" <fr***@frank.com> schrieb
Hello,
I have as class and when I get wrong data when creating the object
(in the 'new' routine) I want to break off the creation of the
classObject, so it results in 'nothing' to the creator . How can I do
that? Thanx
Frank


Catch the error in the procedure creating the object.
Optionally/Additionally add a shared function to the class creating the
object and returning Nothing if an exception was thrown.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
* "Frank" <fr***@frank.com> scripsit:
I have as class and when I get wrong data when creating the object (in the
'new' routine) I want to break off the creation of the classObject, so it
results in 'nothing' to the creator . How can I do that?


Throw an exception in the ctor. Alternatively, you can provide a shared
method that returns an object of the class' type or 'Nothing' if
creation fails.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schrieb
* "Frank" <fr***@frank.com> scripsit:
I have as class and when I get wrong data when creating the object
(in the 'new' routine) I want to break off the creation of the
classObject, so it results in 'nothing' to the creator . How can I
do that?


Throw an exception in the ctor. Alternatively, you can provide a
shared method that returns an object of the class' type or 'Nothing'
if creation fails.


Good suggestion! ;-)
--
Armin

Nov 20 '05 #4

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

Similar topics

14
by: Jeff | last post by:
Ok. I am creating a table in an access DB based on a form submission. This works fine. The problem I am having is, if there is a space in the submission. For example.... someone submits "The...
4
by: Zork | last post by:
Hi, I am trying to stop object creation (in this case ill use a ball as the object) via use of exceptions. In essence, if the ball does not have an owner, I do not want the ball object created....
3
by: Steven Blair | last post by:
Hi, I have a trace log file for a system I am writing. If the creation date is older than 14 days, I have to rename that file (File.Move). The next time a trace message is required a new file is...
5
by: TheNortonZ | last post by:
Are there any preferred methods on : 1. asking a user to register your app 2. giving them the ability to register online and creating a serial number 2. stop the apps usage after a set period of...
3
by: Nick Dreyer | last post by:
I was quite surprised to notice that Sub New() gets called twice, once at declaration time and once at creation time. I can't figure out why it would be called at declaration if there is no class...
1
by: Good Man | last post by:
Hi there I've noticed some very weird things happening with my current MySQL setup on my XP Laptop, a development machine. For a while, I have been trying to get the MySQL cache to work....
56
by: valentin tihomirov | last post by:
{ int i = 2; } int i = 1; There is no 'i' defined in the 'parent' context from the moment of declaration on. So what is the problem? They tell us they pursue language simplicity. The rule "do...
0
by: =?windows-1256?B?2sfV4yDayM8gx+Hh2O3d?= | last post by:
Excuse me!! Would you stop for a moment?! O...man...Haven't you thought-one day- about yourself ? Who has made it? Have you seen a design which hasn't a designer ?! Have you seen a...
0
by: the.great.win.aljana | last post by:
Excuse me!! Would you stop for a moment?! O...man...Haven't you thought-one day- about yourself ? Who has made it? Have you seen a design which hasn't a designer ?! Have you seen a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.