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

IDE debugging question

I'm hoping there's a way to do this, because my present technique
wastes a lot of time.

Suppose I have this console app:

Module Module1

Sub Main()
Dim a As Integer = 1
Dim b As Integer = 0
Dim c As Integer = a \ b
End Sub

End Module

When I run this from within the IDE, obviously execution will halt with
a divide by zero exception when attempting to assign to c. The
dialogbox presented to me tells me the exception type, and 'Additional
information' which is in fact the exception's Message property. The
buttons I can click are Break and Continue. If I click Continue,
execution ends, which is fine.

If I click Break, I am now in debug mode in the IDE and can I have the
command line and all the usual debug tools, so I can (in this example)
examine b and see that it is indeed zero, and understand why I got my
exception.

However. In a more real-world example, some of the information that
would help debug would be *in the Exception that has just been thrown*.
My question therefore is:

Once I have clicked Break and entered debug mode, is there any way to
obtain / interrogate / anything! the Exception which got me here?

--
Larry Lard
Replies to group please

Nov 21 '05 #1
4 1083
Larry,

Sorry if I miss your point here. Can you not use the Try Catch block, and
have it show you the exception?

ie.

Try
Dim a As Integer = 1
Dim b As Integer = 0
Dim c As Integer = a \ b
Catch ex as exception
msgbox(ex.message)
End Try

Rgds,

Phil

"Larry Lard" <la*******@hotmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
I'm hoping there's a way to do this, because my present technique
wastes a lot of time.

Suppose I have this console app:

Module Module1

Sub Main()
Dim a As Integer = 1
Dim b As Integer = 0
Dim c As Integer = a \ b
End Sub

End Module

When I run this from within the IDE, obviously execution will halt with
a divide by zero exception when attempting to assign to c. The
dialogbox presented to me tells me the exception type, and 'Additional
information' which is in fact the exception's Message property. The
buttons I can click are Break and Continue. If I click Continue,
execution ends, which is fine.

If I click Break, I am now in debug mode in the IDE and can I have the
command line and all the usual debug tools, so I can (in this example)
examine b and see that it is indeed zero, and understand why I got my
exception.

However. In a more real-world example, some of the information that
would help debug would be *in the Exception that has just been thrown*.
My question therefore is:

Once I have clicked Break and entered debug mode, is there any way to
obtain / interrogate / anything! the Exception which got me here?

--
Larry Lard
Replies to group please

Nov 21 '05 #2

Sure, if I *had* a Try Catch block. But sometimes (and keep this one
just between us :)) I write code that isn't wrapped in a Try. Shocking,
I know. My present technique - the one which wastes time - is that when
I *do* get an unexpected exception, I then end execution, wrap the
relevant bit in a Try, then run again and follow the same code path to
get to that place, only this time I am waiting to Catch the exception.

I was hoping I could avoid having to make myself habitually put
everything in a Try block. I've changed coding practice in the past, so
it's possible - but I'd rather be able to just access the exception
that's made me break execution.
Phil wrote:
Larry,

Sorry if I miss your point here. Can you not use the Try Catch block, and
have it show you the exception?

ie.

Try
Dim a As Integer = 1
Dim b As Integer = 0
Dim c As Integer = a \ b
Catch ex as exception
msgbox(ex.message)
End Try

Rgds,

Phil

"Larry Lard" <la*******@hotmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
I'm hoping there's a way to do this, because my present technique
wastes a lot of time.

Suppose I have this console app:

Module Module1

Sub Main()
Dim a As Integer = 1
Dim b As Integer = 0
Dim c As Integer = a \ b
End Sub

End Module

When I run this from within the IDE, obviously execution will halt with
a divide by zero exception when attempting to assign to c. The
dialogbox presented to me tells me the exception type, and 'Additional
information' which is in fact the exception's Message property. The
buttons I can click are Break and Continue. If I click Continue,
execution ends, which is fine.

If I click Break, I am now in debug mode in the IDE and can I have the
command line and all the usual debug tools, so I can (in this example)
examine b and see that it is indeed zero, and understand why I got my
exception.

However. In a more real-world example, some of the information that
would help debug would be *in the Exception that has just been thrown*.
My question therefore is:

Once I have clicked Break and entered debug mode, is there any way to
obtain / interrogate / anything! the Exception which got me here?

--
Larry Lard
Replies to group please


Nov 21 '05 #3
Tym
On 28 Jul 2005 10:48:57 -0700, "Larry Lard" <la*******@hotmail.com>
wrote:
Sub Main()
Dim a As Integer = 1
Dim b As Integer = 0
Dim c As Integer = a \ b
End Sub


What's wrong with
Sub Main()
On Error Goto Error_Trap
Dim a As Integer = 1
Dim b As Integer = 0
Dim c As Integer = a \ b

Exit Sub
Error_Trap:
Select Case Err.Number
Case 11
'Divide by Zero Error
Msgbox "You've tried to divide by Zero!"
'Obviously you can display any relevant information _
here about variables....
Error.Clear
Case Else
MsgBox Err.Number & ": " & Err.Description & " " _
& Err.Source
Err.Clear
End Select
End Sub

---
Tym

Please do not adjust your brain, there is a fault with reality
Nov 21 '05 #4
"Larry Lard" <la*******@hotmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
.. . .
However. In a more real-world example, some of the information that
would help debug would be *in the Exception that has just been
thrown*.


And that's exactly what you get handed to you in an Exception Handler.

Try
c = 1 / 0
Catch ex As DivideByZeroException
MsgBox( ex.Message )
Catch ex As Exception
MsgBox( "Did anyone get the number of that truck?" _
& vbCRLF & ex.ToString() _
)
End Try

HTH,
Phill W.
Nov 21 '05 #5

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

Similar topics

2
by: Steve Anderson | last post by:
Please excuse my ignorance as I'm fairly new to ASP. We have IIS running on Win2000 and serving out an ASP application. I installed the script debugger tonight. IE6 on the machine has Disable...
5
by: Bob Bamberg | last post by:
Hello All, I have been trying without luck to get some information on debugging the Runtime Error R6025 - Pure Virtual Function Call. I am working in C++ and have only one class that is derived...
0
by: ZMan | last post by:
Scenario: This is about debugging server side scripts that make calls to middle-tier business DLLs. The server side scripts are legacy ASP 3.0 pages, and the DLLs are managed DLLs...
7
by: Frank | last post by:
I'm running a mixed ASP / ASP.NET environment. I can use the debugger in for the ASP.NET code, no problems. But when I turn on ASP Debugging for the project, I get the error message: "Error...
2
by: Alex Clark | last post by:
Hi All, My system: WinXP Pro, VS.NET 2003, SQL Server Personal Edition. I'm having problems with my old favourite demon, SQL Debugging from within VS.NET. I have to say I've found this...
5
by: Velvet | last post by:
Can someone tell me to what process I need to attach to be able to step through my classic ASP code in VS.net 2003. I'm working on an XP box with IIS installed. I also have VS.net 2005 (The...
0
by: Günter Prossliner | last post by:
Hi everybody! The same question I have asked about one week ago in the german asp.net newsgroup, but no one was able to answer the question. Maybe someone is able to in this group! I...
8
by: razael1 | last post by:
I am putting debugging messages into my program by putting blocks that look like this: #ifdef DEBUG errlog << "Here is some information"; #endif All these #ifdef blocks make the code bulky and...
5
by: phnimx | last post by:
Hi , We have developed a number of plug-in .NET Library Components that we typically deploy with our various applications by installing them into the GAC. Each of the applications contains an...
0
by: Peted | last post by:
I suspect there is a better forum for this question, but i couldnt find it. If someone could point me in the right direction or help me with this question it would be muchly appreciated I have...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
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...
0
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...

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.