Results 1 to 3 of 3

Thread: [RESOLVED] error messages during build

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    64

    Resolved [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.

  2. #2
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    Re: error messages during build

    i'm assuming that the items are strings so cast the object to type string

    either use...
    VB Code:
    1. Select Case DirectCast(nop_combo.SelectedItem, String)
    or...
    VB Code:
    1. Select Case CType(nop_combo.SelectedItem, String)

    this should fix the problem

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    64

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width