Click here to Skip to main content
15,896,557 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionObject reference not set to an instance of an object [modified] Pin
ASPnoob27-Jul-07 19:36
ASPnoob27-Jul-07 19:36 
AnswerRe: Object reference not set to an instance of an object Pin
Christian Graus27-Jul-07 19:54
protectorChristian Graus27-Jul-07 19:54 
AnswerRe: Object reference not set to an instance of an object Pin
Paul Conrad27-Jul-07 19:58
professionalPaul Conrad27-Jul-07 19:58 
GeneralRe: Object reference not set to an instance of an object Pin
ASPnoob27-Jul-07 20:49
ASPnoob27-Jul-07 20:49 
GeneralRe: Object reference not set to an instance of an object Pin
Paul Conrad27-Jul-07 21:08
professionalPaul Conrad27-Jul-07 21:08 
GeneralRe: Object reference not set to an instance of an object Pin
ASPnoob27-Jul-07 21:30
ASPnoob27-Jul-07 21:30 
GeneralRe: Object reference not set to an instance of an object Pin
Christian Graus27-Jul-07 21:35
protectorChristian Graus27-Jul-07 21:35 
AnswerRe: Object reference not set to an instance of an object Pin
Christian Graus27-Jul-07 21:40
protectorChristian Graus27-Jul-07 21:40 
ASPnoob wrote:
For i = 0 To CarsNamesLBox.Items.Count - 1



ASPnoob wrote:
SELECT CarID, Model From CarsTB where Make = 'CarsNamesLBox.Items(i).Text'",


Oh, I didn't even spot that ( I think the other poster did ).

SELECT CarID, Model From CarsTB where Make = '" & CarsNamesLBox.Items(i).Text & "'",

I am pretty sure this is what the code looked like when I first saw it, actually. If you further mangle your code, post it in a reply, not by editing the post. Change it to

SELECT CarID, Model From CarsTB where Make = '" & CarsNamesLBox.SelectedItem.Text & "'"

add a check to see if CarsNamesLBox.SelectedItem = Nothing, and get rid of the loop. That's what I told you to do in the first place. Beyond that, if you're getting this exception, you need to go into the debugger, set a breakpoint on the line, and type things like CarsNamesLBox and CarsNamesLBox.SelectedItem and CarsNamesLBox.SelectedItem.Text, until you find the property that has a value of Nothing, which is what is causing your error.

And, in future, be aware that things can be uninitialised, and write code that checks, so it can fail gracefully.




Christian Graus - Microsoft MVP - C++

"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

AnswerMessage formatting question (expires on sunday) Pin
Luc Pattyn27-Jul-07 23:24
sitebuilderLuc Pattyn27-Jul-07 23:24 
GeneralRe: Message formatting question (expires on sunday) Pin
ASPnoob28-Jul-07 7:55
ASPnoob28-Jul-07 7:55 
GeneralRe: Message formatting question (expires on sunday) Pin
Luc Pattyn28-Jul-07 9:08
sitebuilderLuc Pattyn28-Jul-07 9:08 
GeneralRe: Message formatting question (expires on sunday) Pin
ASPnoob28-Jul-07 13:47
ASPnoob28-Jul-07 13:47 
GeneralRe: Message formatting question (expires on sunday) Pin
Luc Pattyn28-Jul-07 13:57
sitebuilderLuc Pattyn28-Jul-07 13:57 
Questionhow to make a word pad like application in vb.net Pin
eyes200727-Jul-07 19:33
eyes200727-Jul-07 19:33 
AnswerRe: how to make a word pad like application in vb.net Pin
Paul Conrad27-Jul-07 19:34
professionalPaul Conrad27-Jul-07 19:34 
GeneralRe: how to make a word pad like application in vb.net Pin
eyes200727-Jul-07 20:21
eyes200727-Jul-07 20:21 
GeneralRe: how to make a word pad like application in vb.net Pin
Paul Conrad27-Jul-07 20:34
professionalPaul Conrad27-Jul-07 20:34 
GeneralRe: how to make a word pad like application in vb.net Pin
eyes200727-Jul-07 21:19
eyes200727-Jul-07 21:19 
GeneralRe: how to make a word pad like application in vb.net Pin
Paul Conrad28-Jul-07 5:48
professionalPaul Conrad28-Jul-07 5:48 
AnswerRe: how to make a word pad like application in vb.net Pin
BarCode28-Jul-07 5:31
BarCode28-Jul-07 5:31 
GeneralRe: how to make a word pad like application in vb.net Pin
Paul Conrad28-Jul-07 5:49
professionalPaul Conrad28-Jul-07 5:49 
QuestionString compare from different text files Pin
sweehin1827-Jul-07 12:38
sweehin1827-Jul-07 12:38 
AnswerRe: String compare from different text files Pin
Christian Graus27-Jul-07 13:00
protectorChristian Graus27-Jul-07 13:00 
GeneralRe: String compare from different text files Pin
sweehin1827-Jul-07 13:33
sweehin1827-Jul-07 13:33 
GeneralRe: String compare from different text files Pin
Christian Graus27-Jul-07 14:35
protectorChristian Graus27-Jul-07 14:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.