Click here to Skip to main content
15,893,381 members
Posted
Comments
PhilLenoir 28-Aug-14 14:10pm    
You should implement a try/catch block to catch the exception. If you're running in debug, you should see the line that causes the error. If it's at run-time, the error display should show the line number. Turn on line numbers and you should be able to tell exactly what the problem is.

1 solution

Don't be annoyed: they are different types of error.
The errors "you get out of VB" are called compilation errors.
The error you are getting now is called a runtime error, and it can;t be detected at compile time - because it is an error in your logic as expressed in the program, not in the language used to express it.

It's similar to English:
"The toast on child marmalade spread" is not an English sentence: it fails the syntax checks - it's has compilation errors
"The child spread marmalade on toast" is an English sentence: it doesn't fail syntax checks.
"The toast spread child on marmalade" is also an English sentence: it passes the syntax checks, but fails the logic tests in that it makes no sense.

So your program passes the Syntax (compilation) checks, but has run time errors (what it is doing makes no sense).

Exactly why not is not something we can answer: not without more information. But you can: you can use the debugger to tell you. When the error happens, the debugger will stop executing and show you which line is causing the problem. Don't stop executing there! Use the debugger to see exactly which part of the line is wrong by hovering the mouse over the variables: something in it is evaluating to a null (Nothing in VB) followed by a '.' and a property or method. Since it is null (Nothing) it can't be on the left of a '.' because there is no object to make the method work on!

Why is it null? Don;'t know - but once you know what it is, it's generally a fairly simple matter to look back through your code to find out why it isn't set to anything. And if that doesn't show it up, put a breakpoint at the start and step through your code.

We can't do any of that for you: but it's a lot simpler than it sounds!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900