Hi,
Does this bit of code represent complete overkill?!
Try
'create a treenode
Dim tn as new TreeNode()
'add it to a treeview
tv.Nodes.Add(tn )
'do some other stuff
Catch ee As Exception 'something weird has happened
Try
'try to remove the treenode from the treeview
if (tn.TreeView <Null) tn.Remove()
Catch ee As Exception 'now things have got really dire
MessageBox.Show ("Would a function like TreeNode.Remove () ever cause
a random exception that i should worry about?")
End Try
End Try
What i basically mean is ... if this situation arises then someone has
probably poured a cup of coffee into the computer so i won't have to
worry about my software/data being 'recoverable', or will this sort of
*hilarious* thing never happen?
Explanations, musings and criticism all welcome,
James Randle. 5 1481
"pigeonrand le" <pi**********@h otmail.comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
Hi,
Does this bit of code represent complete overkill?!
I'd say overkill. Your app should have some sort of general method of
catching an exception and i think this comes into that category. Have a
look at the Application.Thr eadException event.
Michael
"pigeonrand le" <pi**********@h otmail.comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
Hi,
Does this bit of code represent complete overkill?!
Please don't multipost.
I did go to the trouble of converting the code to VB. Besides, it's
nice to get different people's opinions.
James.
Michael C wrote:
"pigeonrand le" <pi**********@h otmail.comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
Hi,
Does this bit of code represent complete overkill?!
Please don't multipost.
pigeonrandle wrote:
Does this bit of code represent complete overkill?!
Try
Dim tn as new TreeNode()
tv.Nodes.Add(tn )
The only thing that you could usefully recover from is the Nodes.Add,
which means that you won't have anything to remove, so why bother?
Catch ee As Exception 'something weird has happened
Try
if (tn.TreeView <Null) tn.Remove()
Not sure if this even works - Object references should be compared using
the Is operator; I've not come acorss "Null" in Visual Basic.
if this situation arises then someone has probably poured a cup of
coffee into the computer so i won't have to worry about my software/data
being 'recoverable', or will this sort of *hilarious* thing never happen?
I've not [yet] seen a CaffeinatedBeve rageSpillageExc eption - but there's
a /lot/ of new stuff in VB'2005... ;-)
Regards,
Phill W.
Phill,
Amusing. Have you looked in the System.Applicat ion.User.Stupid
namespace?
James.
Phill W. wrote:
pigeonrandle wrote:
Does this bit of code represent complete overkill?!
Try
Dim tn as new TreeNode()
tv.Nodes.Add(tn )
The only thing that you could usefully recover from is the Nodes.Add,
which means that you won't have anything to remove, so why bother?
Catch ee As Exception 'something weird has happened
Try
if (tn.TreeView <Null) tn.Remove()
Not sure if this even works - Object references should be compared using
the Is operator; I've not come acorss "Null" in Visual Basic.
if this situation arises then someone has probably poured a cup of
coffee into the computer so i won't have to worry about my software/data
being 'recoverable', or will this sort of *hilarious* thing never happen?
I've not [yet] seen a CaffeinatedBeve rageSpillageExc eption - but there's
a /lot/ of new stuff in VB'2005... ;-)
Regards,
Phill W.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gary.Hu |
last post by:
I was trying to catch the Arithmetic exception, unsuccessfully.
try{
int a = 0, b = 9;
b = b / a;
}catch(...){
cout << "arithmetic exception was catched!" << endl;
}
After ran the program, it quitted with core dumped.
%test
|
by: Rob Nicholson |
last post by:
Why doesn't try..catch work on my asp.net page?
Try
Dim n As Integer = 10
n = n / 0
Catch ex As Exception
' ignore error
End Try
When I single step over the n=n/0 line, it goes straight to the standard
|
by: CarpetMnuncher! |
last post by:
=================================================================
How do I use Try Catch error handling when a timer is involved?
If I preform the preciduer below and I get an error I revive
50,000,000,000,000,000, messageboxes..
example 1;
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Try
If Label13.Text = ("some text") = False Then
|
by: Bob |
last post by:
Hi,
The compiler gives Warning 96 Variable 'cmdSource' is used before it has
been assigned a value. A null reference exception could result at runtime.
Dim cmdSource as SQlClient.SQLDataReader
Try
Set up the database read and do it.
Catch ex as system.exception
exception stuff here
Finally
|
by: RipperT |
last post by:
Hello,
I am using VB2005. I would like to check a textbox to see if it is blank
using a Try Catch block. I assumed an easy way to do that would be to
perform some action on the string that can't be done if the text box is
blank, then catch it. But I can't find an action to perform that errors if
the text box is blank. I don't want to use If Then Else. Can anyone help?
Rip
| |
by: pigeonrandle |
last post by:
Hi,
Does this bit of code represent complete overkill?!
try
{
//create a treenode
TreeNode tn = new TreeNode();
//add it to a treeview
tv.Nodes.Add(tn);
|
by: Morten Snedker |
last post by:
The use of Try in the Finally part - is that overkill?. I think of the
code failing before opening sqlCon - that would generate an error in
the Finally part. How would Finally handle that?
Try
Dim cmd As New SqlCommand
cmd.CommandText = "spSetAdLinks"
cmd.CommandType = Data.CommandType.StoredProcedure
cmd.Connection = sqlCon
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |