error line source code

is there a way to get the actual line of source code of an error that
occurs?

i.e. source code: a=1/0

error description returns "a=1/0"

i can think of an ugly way of doing it, basically put line numbers in
the code to get the error line, then compare that to the .frm text and
copy the text where it matches on the line number. I am hoping there
is a better and easier way.
0
a
2/18/2010 11:44:36 PM
vb.general.discussion 1016 articles. 0 followers. Follow

10 Replies
1203 Views

Similar Articles

[PageSpeed] 39

<a@b.com> wrote in message 
news:evjrn5h19kksf64fhea3k0qg07oefro6sb@4ax.com...
> is there a way to get the actual line of source code of an error that
> occurs?
>
> i.e. source code: a=1/0
>
> error description returns "a=1/0"
>
> i can think of an ugly way of doing it, basically put line numbers in
> the code to get the error line, then compare that to the .frm text and
> copy the text where it matches on the line number. I am hoping there
> is a better and easier way.

Use the free MZTools Addin to add line numbers, and use Erl function to get 
the line number.



0
Nobody
2/19/2010 2:23:23 AM
"Nobody" <nobody@nobody.com> wrote in message 
news:%238E1SqQsKHA.5356@TK2MSFTNGP02.phx.gbl...
> <a@b.com> wrote in message 
> news:evjrn5h19kksf64fhea3k0qg07oefro6sb@4ax.com...
>> is there a way to get the actual line of source code of an error that
>> occurs?
>>
>> i.e. source code: a=1/0
>>
>> error description returns "a=1/0"
>>
>> i can think of an ugly way of doing it, basically put line numbers in
>> the code to get the error line, then compare that to the .frm text and
>> copy the text where it matches on the line number. I am hoping there
>> is a better and easier way.
>
> Use the free MZTools Addin to add line numbers, and use Erl function to 
> get the line number.

but like he says, he then still wants to get the code text at that line 
number, i thought that was what he was looking for a way to do?
mark 


0
mp
2/19/2010 10:33:42 PM

"mp" <nospam@thanks.com> wrote in message 
news:e5wUaObsKHA.5036@TK2MSFTNGP02.phx.gbl...
>
> "Nobody" <nobody@nobody.com> wrote in message 
> news:%238E1SqQsKHA.5356@TK2MSFTNGP02.phx.gbl...
>> <a@b.com> wrote in message 
>> news:evjrn5h19kksf64fhea3k0qg07oefro6sb@4ax.com...
>>> is there a way to get the actual line of source code of an error that
>>> occurs?
>>>
>>> i.e. source code: a=1/0
>>>
>>> error description returns "a=1/0"
>>>
>>> i can think of an ugly way of doing it, basically put line numbers in
>>> the code to get the error line, then compare that to the .frm text and
>>> copy the text where it matches on the line number. I am hoping there
>>> is a better and easier way.
>>
>> Use the free MZTools Addin to add line numbers, and use Erl function to 
>> get the line number.
>
> but like he says, he then still wants to get the code text at that line 
> number, i thought that was what he was looking for a way to do?
> mark
>

I missed that at first too, thinking the same as Nobody in adding line 
numbers and the Erl function. He can't get the actual code. Best he can do 
is report the line number and then find that line number in his source code. 
If you don't make your line numbers unique throughout the entire project, 
the error message should also identify the procedure by name (which has to 
be a literal string).

-- 
Mike
 

0
MikeD
2/19/2010 10:57:33 PM
yes, i want the actual code. 

If I'm on the road or away from my computer and I get a support email
on my blackberry or something, which lists only the line number, it
doesn't help me much. If I know the error source, I can perhaps think
of what might be happening.

looks like i'll have to do it the way i propose...make txt files of
the .frm's and do local lookup based on the form name and error line
number. Then send that along.

thanks for the replies.




On Fri, 19 Feb 2010 17:57:33 -0500, "MikeD" <nobody@nowhere.edu>
wrote:

>
>
>"mp" <nospam@thanks.com> wrote in message 
>news:e5wUaObsKHA.5036@TK2MSFTNGP02.phx.gbl...
>>
>> "Nobody" <nobody@nobody.com> wrote in message 
>> news:%238E1SqQsKHA.5356@TK2MSFTNGP02.phx.gbl...
>>> <a@b.com> wrote in message 
>>> news:evjrn5h19kksf64fhea3k0qg07oefro6sb@4ax.com...
>>>> is there a way to get the actual line of source code of an error that
>>>> occurs?
>>>>
>>>> i.e. source code: a=1/0
>>>>
>>>> error description returns "a=1/0"
>>>>
>>>> i can think of an ugly way of doing it, basically put line numbers in
>>>> the code to get the error line, then compare that to the .frm text and
>>>> copy the text where it matches on the line number. I am hoping there
>>>> is a better and easier way.
>>>
>>> Use the free MZTools Addin to add line numbers, and use Erl function to 
>>> get the line number.
>>
>> but like he says, he then still wants to get the code text at that line 
>> number, i thought that was what he was looking for a way to do?
>> mark
>>
>
>I missed that at first too, thinking the same as Nobody in adding line 
>numbers and the Erl function. He can't get the actual code. Best he can do 
>is report the line number and then find that line number in his source code. 
>If you don't make your line numbers unique throughout the entire project, 
>the error message should also identify the procedure by name (which has to 
>be a literal string).

0
a
2/19/2010 11:41:38 PM
<a@b.com> wrote in message 
news:v18un5dnv2apsh63otrhcv7f0h8mbh1m20@4ax.com...
|
| yes, i want the actual code.
|

Can't be done.

You could copy each line of your code into a string and pass that string to 
your error handling routine...but not only would that take forever and bloat 
the size of your app, but anyone with a hex editor could view your app's 
code.

If you know your app and how your code works, a reference to the line number 
should be all you need to debug it. 


0
C
2/20/2010 1:54:13 AM
<a@b.com> schrieb im Newsbeitrag 
news:v18un5dnv2apsh63otrhcv7f0h8mbh1m20@4ax.com...
>
> yes, i want the actual code.
>
> If I'm on the road or away from my computer and I get a support email
> on my blackberry or something, which lists only the line number, it
> doesn't help me much. If I know the error source, I can perhaps think
> of what might be happening.
>
> looks like i'll have to do it the way i propose...make txt files of
> the .frm's and do local lookup based on the form name and error line
> number. Then send that along.
>
> thanks for the replies.
>

Why this way around? Seeing the actual line of code where the error
occurs may help, but more often you'll need the context, the last 2 or
5 lines before. So I would put the source files with the line numbers
onto an USB-Stick or Memory stick or whatever your "blackberry or
something" supports and then look it up with the text editor of this
device. Or - with a blackberry - download the data from a server.

Helmut. 

0
Helmut
2/20/2010 9:45:37 AM
As others have stated, getting the line number is the best you can do. I 
have been using a product called VB Builder from GridLinx. It has functions 
to make it easy to add error handling to your procedures which will report 
the line number, error description, module and procedure name where the 
error occured. The build function will make a copy of your original source 
code and add line numbers to the executable lines code and keep it in a 
separate 'build' folder. That way you can keep your original source code 
clean and free of line numbers and not have to worry about renumbering or 
inserting new line numbers when you modify your code.

Just make sure you take a copy of the build source code with the line 
numbers for reference.

0
Daryl
2/20/2010 5:43:01 PM
"Daryl Muellenberg" <dmuellenberg@comcast.net> wrote in message 
news:A0B6FE1F-534E-42BE-9261-C047521A3D5A@microsoft.com...
> As others have stated, getting the line number is the best you can do. I 
> have been using a product called VB Builder from GridLinx. It has 
> functions to make it easy to add error handling to your procedures which 
> will report the line number, error description, module and procedure name 
> where the error occured. The build function will make a copy of your 
> original source code and add line numbers to the executable lines code and 
> keep it in a separate 'build' folder. That way you can keep your original 
> source code clean and free of line numbers and not have to worry about 
> renumbering or inserting new line numbers when you modify your code.
>
> Just make sure you take a copy of the build source code with the line 
> numbers for reference.

I checked the assembly output of how VB6 adds line numbers, and impact on 
performance. I found that VB adds something like the following pseudo code:

Some32BitsGlobalVar = 100

Where "100" is the line number, and in assembly, it looks like this:

mov DWORD PTR [12345678], 100

This probably takes one or two CPU clocks, I am not sure. So it doesn't add 
much unless you have a tight loop and performance is important.



0
Nobody
2/20/2010 6:53:03 PM
On 19/02/2010 23:41, a@b.com wrote:

> yes, I want the actual code.

Not unless you write code like

17   sCode = "hFile = FreeFile()"
18   hFile = FreeFile()

19  sCode = "Open sFile for Output as #hFile"
20  Open sFile for Output as #hFile

> If I'm on the road or away from my computer and I get a support email
> on my blackberry or something, which lists only the line number, it
> doesn't help me much. If I know the error source, I can perhaps think
> of what might be happening.

I would suggest that you know your [own] code immensely well.

This is the kind of thing I used to be able to do when I was a 
"hobbyist" coder and when the programs were mine and mine alone.  Now I 
work in a sizeable team of Developers, any number of which could be 
working on any particular application, and I just can't maintain that 
level of intimacy with "my" codebase any more.

Also, I would argue that the code itself is not enough for any kind of 
real diagnosis (unless the code itself is completely rubbish and would 
have blown up anyway).

"Bad Code Breaks.  Good Code get broken (by Bad Data)."

You need to know /which/ function failed (the line number is a bonus but 
by no means essential) and the /data/ with which that function was called.
Then you need to know which /other/ function called the one that failed 
and with what data and so on, all the way back up the chain.
Yes; it's a pain having to add all the instrumentation code to keep 
track of this, but it makes for far more effective diagnosis.

(Brace yourselves, all; 'N'-word coming...)

..Net goes /some/ way towards addressing this; its Exception class hands 
you a Stack Trace of /where/ the problem occurred, but it still utterly 
fails to give you the really /useful/ stuff - the scuzzy piece of data 
that's taken your program down.

> looks like i'll have to do it the way i propose...make txt files of
> the .frm's and do local lookup based on the form name and error line
> number. Then send that along.

Now hold on a minute.  Are you suggesting that you're going to ship 
copies of all your source code to your clients, just so that you can 
ship a few lines of it back to yourself in the event of an error?
If they've got all of that (and a kosher copy of VB) what do they need 
you for, again?  :-)

I would suggest that you continue to ship back the file name and line 
number (a common enough diagnostic seen in 'C' programs) but keep the 
source code with you but then:
How many code files are you going to have to carry around?
How are you going to ensure that you have the /latest/ ones?  That 
no-one else has made a change and not told you about it?

Just my tuppence-worth.  ;-)

HTH,
    Phill  W.
0
Phill
2/22/2010 1:18:43 PM
"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-k> wrote

> You need to know /which/ function failed (the line number is a bonus but
> by no means essential) and the /data/ with which that function was called.
> Then you need to know which /other/ function called the one that failed
> and with what data and so on, all the way back up the chain.
> Yes; it's a pain having to add all the instrumentation code to keep
> track of this, but it makes for far more effective diagnosis.

Its rather amusing.  I wrote a Log Manager article for a book that did this
sort of thing way back in 1998.  As you say it requires the instrumentation
code to make it all work, but that kind of code can be automated.

Basically the program would call the manager at the start and end of every
procedure.  The first call gives the procedure name and all the parameters,
and the exit call passes in the procedure name.  From that, a current call
stack could be maintained all while the program runs, then saved to disk
(or shown to the user, or sent via email, whatever...)  at the first sign of
trouble.

Its not that dificult to do, once you get past the idea that you want to
do it....

FYI: http://www.amazon.com/Waite-Groups-Visual-Source-Library/dp/0672313871

LFS


0
Larry
2/22/2010 2:53:12 PM
Reply:

Similar Artilces:

Excel Progrom Error
Hi there Happy new year to all. I often receive the folowing error message in a box titled "Program Error". EXCEL.exe has generated errors and will be closed by Windows. You will need to restart the program. An error log is being created. The only option is OK which closes Excel. I do not know where the error log is created. I am using Office 2000 Service Pack 3 with Windows 2000 Professsional Service Pack 4. Can anybody throw some light on this error. Thanks in anticipation. Michael What are you doing at the time (i.e. is it consistent)? -- Regards; Rob ----------------...

Sharebuilder account import error
Invalid .qif header error when trying to import .qif file from sharebuilder accounts. Anyone know of a fix or experienced this problem?? I typed a long mail to sharebuilder regarding this issue...still waiting fora reply. Hopefully they will be able to help. Microsoft flat out told me it wasn't their issue and to contact my broker! No help AT ALL. Microshaft..... OMalley ...

DPM2010 RC Errors on secondary server.
We have recently upraded our 2007 SP1 Primary DPM server to 2010 RC and it is working perfectly. I've set up a brand new, fresh Windows 2008 R2 Server for the secondary server, and have told it to protect one of the protection groups on the primary server. Everything works for a little while, but every half hour or so, the DPM service crashes and says: "Connection to the DPM service has been lost. Review the application event log for information about a possible service shutdown. ID: 917" Then asks to restart the administrator console. This kills the ...

ERROR
Hi I am using a spreadsheet in Excel 2002 on Windows XP, for some reason the account numbers (which someone input, along with addresses) have a little green mark in the corner of the cell. I thought it was to show that there is a comment, but it is not. When you click on the cell, a little warning sign shows, saying ERROR - number in this cell formatted as text or preceded by an apostrophe. When I click on the arrow by the warning sign, it says Number stored as text Convert to number Ignore error Edit in formula bar Error checking options Show formula in audinting toolbar Now I looked a...

error, chkdsk
Questio, when I try to open excel or winmx, an error pops up saying chkdsk, so i ran a chkdsk and it doesnt do anything. The error also says corrupted file. In excel I have some important work that I need to open, and it only opens in Turkish, if I change it to English, its a bunch of boxes and letters, its not my work I need. How do I change it back. What excel version are you using? Try to find somebody with 2003 to see if they can open the file. Otherwise you would look for some commercial software that might be of help http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B30...

auto updating source data
Hi I have a matrice that looks something like this: A B 1 service 1000 2 maintenence 500 3 transport 300 4 service 200 5 6 7 8 and from this I like to make a pie-chart with procentage of the costs. The problem is that I never know how many rows I will have and I would like to make my chart's source- data updated automaticaly, so I would have to specify it manually each time. Is this possible? will be thankfull for any comments tnx ...

error 0x800CCC0F
Dear Team; I am receiving the following error messages, please assist Could result be sent to lewis.king@riotinto.com regards Lew Your server has unexpectedly terminated the connection. Possible causes for this include server problems, network problems, or a long period of inactivity. Subject 'brocolli & mushroom stir fry noodle', Account: 'pop.gmail.com', Server: 'smtp.gmail.com', Protocol: SMTP, Port: 995, Secure(SSL): Yes, Error Number: 0x800CCC0F Your server has unexpectedly terminated the connection. Possible causes for this include server p...

4.4.7 error
I have problems on one client that they don't recieve all emails from people sending to them. I guess something is wrong in the configuration. When I do a nslookup -type=mx domain.com I just get unautharized answer. Also the ttl time is just 1800 when I do a dns report. Do the guys that handle the dns change this? The people that doesn't get their mail throw get the 4.4.7 error in return. Best regards Jimmy http://support.microsoft.com/kb/555375 -- Ed Crowley MVP "There are seldom good technological solutions to behavioral problems." .. "Surfer&q...

toolbar, date, services, errors, paste, minimized system restore doesn't work
I have a XP system that the toolbar does not show open programs, services do not seem to load at boot, the date is off by one month, I cannot paste anything that I copy, and system restore does not work. All of these issues started at the same time a few days ago. Has anyone else seen this group of errors? I am trying to resolve and do not know if it is a system update gone bad, or if maybe it is a viruse/malware issue. Please let me know if you had had these problems together and what you did to fix them. There is a very good chance that you are seeing the effects of a hi...

Excel error codes translations
hi, Does anybody know where I can find a kind of dictionary for Exce errors? The problem is sometimes I get an error message that is not in Englis and without error code and then looking for the solution I must kno its equivalent in English. Regards, Micha -- Message posted from http://www.ExcelForum.com ...

delete server...routing master error
hello, I have 2 exchange servers (exch 2003) and i have to delete one of them. I changed all replication etc...(before we had also a 5.5 which is already removed) but when i stop the services and try to remove the server via system manager of my second exchange (the one that will stay) i get an error message that my server that i want to delete is the routing master for that group. How can i make my other server the routing master ? i don't have any site replication (deleted it because not necessary anymore). thnx, Philippe Go to routing groups > first routing group > mem...

Re: Money 2004
Thanks for the suggestion. I tried unregistering/re-registering the msxml3 DLL, but still no luck. However, knowing the help file topics are local might help with debugging this problem. thanks, randy "Randy" <nospam@hotmail.com> wrote in message news:... > All, > > I've recently upgraded to Money 2004 Premium from 2003 Deluxe. I'm now > finding that I can't view any help topics--I get the "Unable to load topic. > Click here to try again." I've tried all the suggestions posted here and at > other sites: cleared out temporary in...

"File Error: Data May Be Lost" error when opening workbook saved in Mac
When I open in Excel 2007 for Windows workbook with charts saved in Mac OS, I see the message "File Error: Data May Be Lost". In Excel 2003 for Windows this message appears as many times as many sheets there are in workbook. Maybe someone knows what's the reason? Unfortunately you haven't provided the info needed... "Mac OS" means very little. The question is "What version of Mac Excel are you using, what file format are the files saved as & what type of content is in the files?" In general, what you're running into is that Excel 2003 &a...

Technical error
AMEX and Discover are not being sent over to the credit card processor during settlement. I comes up with a "TECHNICAL ERROR". Visa and MC are settling fine. Does anyone know what the problem is?? All are setup as different tranaction types in RMS and ALL authorize fine during the transaction process. Your merchant account is not correctly configured for AMEX & Discover. This is on the bank's side, not RMS. -- Glenn Adams Tiber Creek Consulting http://www.tibercreek.com glenn@tibercreek.com ---------------------------------------------- Please DO NOT respond to me dir...

CObject Private method access error
Hi, I am trying to recompile application that has been developed in VC++ 6.0 with VC++2005.. While compiling, I'm getting the following error.. error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' 1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\afx.h(553) : see declaration of 'CObject::CObject' 1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\afx.h(524) : see declaration of 'CObject' 1> This diagnostic occurred in the compiler generated function 'CExcepti...

Error in closing Outlook
Application error ciceroUIWndFrame. The instruction at 0x7e430240 reference memory cannot be written 0x7e42631A Also unable to dial a phone using Outlook. Sanford Take a look here http://support.microsoft.com/kb/323613 -- Peter Please Reply to Newsgroup for the benefit of others Requests for assistance by email can not and will not be acknowledged. "Sanford Aranoff" <aranoff@analysis-knowledge.com> wrote in message news:4B6CD165.E7510293@analysis-knowledge.com... > Application error ciceroUIWndFrame. > The instruction at 0x7e430240 reference me...

Can't Erase Tapes: DPM Fails with Error ID:3308
I attempt to erase a tape and every time the DPM console crashes (sometimes two hours into the tape erase) and there is this error: * (000002L4) could not be erased for the following reason: (ID 3308) * DPM service terminated unexpectedly during completion of the job. The termination may have been caused by a system reboot. (ID 910) I can verify that the server has not rebooted. I'm using DPM 2007, with June Rollup, on Windows Server (x64) 2008. The server is a Dell PowerEdge R710. The tape drive is an LTO4 in a Dell PowerVault 124T Autoloader. This error seems to ...

Typing message error
I have an Asus Eee PC netbook which came with a Microsoft Works 2007 trial. I'm unable to type anything on a Word document. An error message flashes briefly at the bottom of the screen, "This modification is not allowed because the selection is locked." I'm baffled. Is this a computer problem or a Works problem and how can this be fixed? Thank you. I would be surprised if any system nowadays came with a Works trial; more likely it is an Office 2007 trial (and if it *is* Works, then you're in the wrong discussion group). If the computer is quite new, then...

Receive an error message when you try to perform any editing tasks
Hi We have exch2003 cluster and recently we have some note book with Vista, now when we are accessing mailbox through OWA we are getting error when we want to edit (reply, forward) there is article from MS, we want to know does this article also apply to exch clsuter or it is for member server. The artical is http://support.microsoft.com/?kbid=911829 Nagori Not sure what you mean by either exch cluster or member server, but basically you will need to install this patch on your FE and BE exchange servers, including your exch cluster servers. To install exch hotfixes or patches, move...

outlook.pst error message
When I attmept to open Outlook 2000 (in Windows XP) I get an error message that the file C:Documents and Setting\Owner Settings\Application Data\Microsoft\Outlook\outlook.pst has detetected an error. It tells me to quit all mail-enabled applications and then use the Inbox repair tool. I have tried to run the repair tool many times and it always crashes before it fin9shes scanning the files. One time it finished the scan and stated that files were damaged and it asked if I wanted to Repair those files. I said yes and it froze up and would not respond. Are there any other ways ...

PM Transaction continuing error message #2
We are currently running GP 10 SP1 and apparently since version 8 (we did not upgrade to 9) there has been the following error message while launching a transaction out of Smartlist, when we go to inquiry for AP documents, and drill down of PMTRX & PMCHK from the JE inquiry view: Unhandeled Script Exception: Index 0 array of 'PM_Transaction_Inquiry_Fill' Script terminated We ran a query for all documents that were less than 1 or greater the 8 on the PM00400 & PM30200 tables. And updated the ones to what they needed to be. And it worked! And the message went away! But then we ...

Message "An error has occured" when click Activity
Hi All, After creating a new case, when i try to create a new email activity, message "An error has occured. Please contact your system administrator". Has anybody encounter this issue before? Previously it was working fine, after we import the customization. I have problem to create new email activity. Thanks. -- Regards, Venedict what does the Event Viewer say? "Venedict" wrote: > Hi All, > > After creating a new case, when i try to create a new email activity, > message "An error has occured. Please contact your system administrator". &g...

error messages #3
I had the error message... > cannot SKU011.cab I soved this by following the instructions listed here. > http://social.msdn.microsoft.com/en-US/Profile/?referrer=http%3a%2f%2fsocial.msdn.microsoft.com%2fForums%2fen-US%2fvssetup%2fthread%2f5493e068-01d3-4e96-a9b1-58020bc94e69%2f&rh=YI7rGXc4iv4rR%2b2JUZeQQv4OEnxWySPD0w%2bJjbDQwzE%3d > Then I received the error message... > 1311 source not found C:\MSOCache\All > Users\90000409-6000-11D3-8CFE-015204838309\PA561401.CAB > I do not have the install disks for Microsoft Office Professional 2003. My > computer was build by som...

Pub error
I get the following message whenever I scan photos in Corel Photopaint and copy paste into Pub 2003. Happens on all my computers. Happens after scanning about 6 pictures or so. Publisher cannot launch or communicate with the OLE server program needed to complete the task. There may not be enough disk space, or there may be a problem with the server program. To make more disk space available, delete some unneeded files on your hard disk. If you suspect a problem with the server program, try reinstalling it. Then try this task again. Is there a way to correct this? Scan your p...

GP upgrade from 8 to 10 error message
I upgrade from GP7.5 to GP8 few months back and now I am trying to upgrade it to GP10 in lab environment. I followed the line by line instruction in upgrade instructions. I also installed sp3 but whenever I try to urn GP Utility it is giving me this error message "Database Name" Advanced security product 3104 does not support upgrading from version 7.50 or prior" "report scheduler Product 3278 does not support upgrading from version 7.50" Any help will be appreciated. Please be gentle it is my first time that I am playing with this product. Thanks, Abid, You m...