VS 2003, vb.net...
Is there a way to determine the line number currently executing in your
code, so you can log this line number information (e.g. via trace)?
Thanks!
Bob Day 5 6095
"Bob Day" <Bo****@TouchTa lk.net> schrieb: VS 2003, vb.net...
Is there a way to determine the line number currently executing in your code, so you can log this line number information (e.g. via trace)?
You can set error numbers by hand:
\\\
Public Sub Bla()
1: Dim i As Integer
2: i = 2
3 Dim s As String = "Hello World"
End Sub
///
When using 'On Error...' error handlers, you can determine the line number
by reading the 'Erl' property of the 'Err' object.
--
Herfried K. Wagner
MVP · VB Classic, VB.NET http://www.mvps.org/dotnet
"Herfried K. Wagner [MVP]" <hi*******@m.ac tivevb.de> schrieb: 3 Dim s As String = "Hello World"
Sorry, the line above should read "3: Dim s As String = "Hello World"".
;-)
--
Herfried K. Wagner
MVP · VB Classic, VB.NET http://www.mvps.org/dotnet
Hi Bob,
The following will give you the line number of your code (as in the source
file):
Dim CurrentStack As System.Diagnost ics.StackTrace
MsgBox (CurrentStack.G etFrame(0).GetF ileLineNumber)
In case you're interested, you can find out about the routine that you're
in as well as all its
callers.
Public Function MeAndMyCaller As String
Dim CurrentStack As New System.Diagnost ics.StackTrace
Dim Myself As String = CurrentStack.Ge tFrame(0).GetMe thod.Name
Dim MyCaller As String = CurrentStack.Ge tFrame(1).GetMe thod.Name
Return "In " & Myself & vbCrLf & "Called by " & MyCaller
End Function
This can be very handy if you want a generalised error routine because it
can get the name of the caller (which would be where the error occurred).
Regards,
Fergus
Thanks for your help.
Howver, using the code you suggest below in various situations always
returns a line number of zero Dim CurrentStack As System.Diagnost ics.StackTrace MsgBox (CurrentStack.G etFrame(0).GetF ileLineNumber)
Any suggestions?
Bob Day
"Fergus Cooney" <fi******@tesco .net> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. Hi Bob,
The following will give you the line number of your code (as in the
source file):
Dim CurrentStack As System.Diagnost ics.StackTrace MsgBox (CurrentStack.G etFrame(0).GetF ileLineNumber)
In case you're interested, you can find out about the routine that
you're in as well as all its callers.
Public Function MeAndMyCaller As String Dim CurrentStack As New System.Diagnost ics.StackTrace Dim Myself As String = CurrentStack.Ge tFrame(0).GetMe thod.Name Dim MyCaller As String =
CurrentStack.Ge tFrame(1).GetMe thod.Name Return "In " & Myself & vbCrLf & "Called by " & MyCaller End Function
This can be very handy if you want a generalised error routine because
it can get the name of the caller (which would be where the error occurred).
Regards, Fergus
Good question. yes, I am running in debug mode. The only thing I could
find on "Program Debug Symbols" in help was:
"To access the Debug Symbol Files property page, right-click on your
Solution in Solution Explorer and choose Properties from the shortcut menu.
Expand the Common Properties folder and click the Debug Symbol Files page. "
However, the "Debug Symbol Files" does not appear as an option as it says it
should above. I presume that means I some how heave it turned off. I don't
see where to turn it on. Where do you turn it on?
Please advise. Thanks for your help.
Bob Day
"Herfried K. Wagner [MVP]" <hi*******@m.ac tivevb.de> wrote in message
news:up******** ******@tk2msftn gp13.phx.gbl... Hello,
"Bob Day" <Bo****@TouchTa lk.net> schrieb: Howver, using the code you suggest below in various situations always returns a line number of zero Dim CurrentStack As System.Diagnost ics.StackTrace MsgBox (CurrentStack.G etFrame(0).GetF ileLineNumber)
Do you run your application in Debug mode? 'GetFileLineNum ber' is only avaliable if Program Debug symbols are available for the application.
-- Herfried K. Wagner MVP · VB Classic, VB.NET http://www.mvps.org/dotnet
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David Abrahams |
last post by:
Is there any way to determine the file and line number (if any) of a
method's invocation from within its body?
Many Thanks in advance,
Dave
--
David Abrahams
Boost Consulting
http://www.boost-consulting.com
|
by: Jim Cobban |
last post by:
I am reading an XML file using Java. I would like to issue diagnostic
messages which identify the original line number in the source, but that
information does not appear to be available during a DOM traversal. I am
using DOM rather than SAX because I want to be able to update the DOM and
then write the updated XML file back out.
--
Jim Cobban jcobban@magma.ca
34 Palomino Dr.
Kanata, ON, CANADA
|
by: Ken Varn |
last post by:
I want to be able to determine my current line, file, and function in my C#
application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___
macros for getting this, but I cannot find a C# equivalent. Any ideas?
--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
varnk@diebold.com
|
by: kangaroo |
last post by:
Hi guys,
when we run a stored proc and it results into an unhandled error, the
error message returned by db2 udb does not contain a line number that
caused an error. This makes it pretty difficult to debug those procs.
Line number have always been there in Oracle messages. When I Googled
on this, I saw some people showing DB2 Stored Proc error messages with
line numbers in them (like LINE NUMBER=1285), which makes me believe
that...
|
by: JohnR |
last post by:
Hi,
I'm looking for some advice and guidance. I have a program in vb.net and I
know that when it's run and the pdb file is available that the exception
will contain the line number of the error. Obviously when trying to track
down an error this is extremely valuable. I've also heard people say that
when you distribute your app, you should compile it without debug and
without the pdb file. In this case the exception has no error...
| |
by: johnivey |
last post by:
I have a large query that I am trying to debug in query analyzer.
However, the errors I get have no line number or reference to where
they are failing. How can I find out what line in the query is causing
a particular error message to appear?
Thanks
John Ivey
South Pike School District
|
by: Daniel |
last post by:
hi guys
i have never understood this so i am hoping someone can help.
I have had errors in my app before where on closing it down i get a
NullReferenceException error thrown BUT no line number given. I have put try
catch state,ents to catch it around every method that fires during shutdown
and none seem to be the cause, due to the lack of line number i am literally
guessing where it could be? What else can i do?
|
by: Jeff Jarrell |
last post by:
I have a block of code that during development is prone to casting errors.
It is mostly a DataReader type thing.
It looks something like this.
_prtPNID = myDLReader.GetString("prtPNID")
_prtSKU = myDLReader.GetString("prtSKU")
_prtPic = myDLReader.GetString("prtPic")
_prtRsvQty = myDLReader.GetInteger("prtRsvQty")
|
by: Horacius ReX |
last post by:
Hi,
I have to search for a string on a big file. Once this string is
found, I would need to get the number of the line in which the string
is located on the file. Do you know how if this is possible to do in
python ?
Thanks
|
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: 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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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.
| |