[RESOLVED] error messages during build
Hi I am debugging an application I have built in vb studio 2002 I then upgraded to vbexpress 2005 it has picked up on what i presume is my bad programing the most common one is that I have several combo boxs where the user can pick an option and dependant on thier selection this or that is done. well the way i have done it vb does not like it comes up with this error message :-
"Warning 32 Operands of type Object used in expressions for 'Select', 'Case' statements; runtime errors could occur."
It is refering to this line of code:-
"Select Case nop_combo.SelectedItem"
what is wrong with using the select case method, and if I cannot use that will the old if then method be any better.
Re: error messages during build
i'm assuming that the items are strings so cast the object to type string
either use...
VB Code:
Select Case DirectCast(nop_combo.SelectedItem, String)
or...
VB Code:
Select Case CType(nop_combo.SelectedItem, String)
this should fix the problem
Re: error messages during build
Thanks that worked a treat I supose the problem was converting object to string. but it seems rediculas that it did not know that whatever is in a combo box must be a string. I presume this is the case as it is just a fancy textbox or am I showing my ignorance yet again I wish I could find a basic referance book that doesn't cost the earth all my knowlege is self taught so there are big gaps!!! anyway thanks for the tip you have saved me hours of messing around experimenting.