Code Review - Please :)

LOL… Jeremy found the same thing I did about 2seconds before I could type a response :slight_smile:

I found it first :stuck_out_tongue:

JOKE

Arghhhhhhh - I did as you advised but when I compile the app and run it - the same thing happens - window doesn’t close and nothing written to the database :frowning: :frowning:

I have a module - db As SQLiteDatabase - would that be a factor?

Richard, the important thing from this is that you’ve learned a new tool that Xojo provides. See how it helped solve this problem? It let us know that db is Nil. Then, and only then, could we begin to look for the source of the real problem. Take a peek at a Webinar Paul did: http://youtu.be/RgK23y6Lq4Y

[quote=91172:@Richard Summers]Arghhhhhhh - I did as you advised but when I compile the app and run it - the same thing happens - window doesn’t close and nothing written to the database :frowning: :frowning:

I have a module - db As SQLiteDatabase - would that be a factor?[/quote]

What does the debugger do? Still a Nil exception?

Hold on a mo - I’ll check again :slight_smile:

Yes - exactly the same, the first time I step through it highlights line 5, and when I press the step button again I get the red bug and Exception: NilObjectException again :frowning:

OK. In the bottom area that shows it is a Nil exception… There should be a Hyperlink down there that says “Self”. Click it. You will then see all the properties on Self. My guess is that db is still Nil?

You gotta figure out why it is Nil. Without seeing more of your code, I’m not sure why it would still be Nil.

Another part of the problem is that you are simply returning True in App.UnhandledException. In other words, the app is generating a serious error and, instead of dealing with it, you are simply masking it, which is why it seems to you that pressing the button “does nothing”.

Here is what I see when I click on the self hyperlink - there is no reference at all to db?

Screenshot

Kem,
should I remove the Return True line then?

Wasn’t even thinking about that. It may be shadowing another problem in another section of code.

Richard, returning True blindly in your App.UnhandledException should be considered a big no-no.

Removed the Return True, and now when I run my app I get a MsgBox with a NilObject Exception message.
Ran it through the debugger again - same problem :frowning:

I have just noticed that I have 2 properties - db As SQLiteDatabase

One is a property of the MainWindow and the other is a property inside a Module.
See screenshot below:

Screenshot

Richard
I don’t want to side track you from your project, but I wanted to say that “Debugging and stepping thru” the code is one of the most important parts of programing. Code review is good but does not always work. Stepping thru the code to verify that it does what you expect will, most of the time.
I would estimate that I debug about 90% of my code this way. Normally you will catch typing errors and logical errors.

When you get code from others use the debugger to learn what goes on. Look at the variables, not only the simple one but also stuff like folderitems, record sets, and other stuff.

Thanks Jim :slight_smile:

Richard - if you have two properties with the same name, you will need to prefix them with the module name or window name, i.e.

MainWindow.db
'or
Module1.db

Thanks Jason.
Due to the above and beyond help from Jeremy Cowgar - it is now solved :slight_smile:

Thank you anyway.