FalconDEW Posted June 17, 2004 Posted June 17, 2004 Ok - please forgive me for this dumb question, but I need help with some basic VB.Net sytax. I want to make use of the combo box .contains method. The method uses "value as object" as it's input. I have a string variable that I want to pass into the method so I can see if my string is contained within the combo box. However, the method keeps generating the "Object reference not set to an instance of an object". How can I reference the string variable correctly? I've tried creating a new object and setting it equal to the string - but I know there is just something stupid I'm missing with my sytax. :mad: -Falcon Quote
wessamzeidan Posted June 18, 2004 Posted June 18, 2004 Can you post some of your code to see where's the problem..... Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
FalconDEW Posted June 18, 2004 Author Posted June 18, 2004 Sure This is a quick example of what will cause the problem - though slightly diferrent than what I was explaining above. The problem I'm having is simply how to get a string referenced correctly so it can be put into a function that requires an 'Object' as input? Dim cmbExample As ComboBox cmbExample.Items.Add("Test") -Falcon Quote
wessamzeidan Posted June 18, 2004 Posted June 18, 2004 the problem is not with the string. If this is how you're doing it then you're only creating a reference to a combobox, you need to initialize it Dim cmbExample As ComboBox cmbExample=New ComboBox() cmbExample.Items.Add("Test") Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
FalconDEW Posted June 18, 2004 Author Posted June 18, 2004 Yeah - you're right. I actually figured out my problem too. I was using 2 different forms and forgot to make the constructor between the forms... so every time I tried to access a variable on the original form it threw the error about object referencing. So - my problem is fixed! Thanks! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.