I am getting a Object warning with my select case statement.

Posted on 2006-03-23
Last Modified: 2011-09-20
I am getting the following warning:

Operands of type Object used in expressions for 'Select', 'Case' statements; runtime errors could occur.

Here is the code that is causing the Warning:
It is on this line: "Select Case Me.lstMemberDescription.SelectedItem"

    Private Sub dtpJoinDate_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

        If Me.lstMemberDescription.SelectedIndex > -1 Then
            Select Case Me.lstMemberDescription.SelectedItem
                Case "Organizational Member"
                    Me.dtpCancelDate.Value = Now
                Case "Ovation Voter"
                    Me.dtpCancelDate.Value = Now
                Case "Subscription only"
                    Me.dtpCancelDate.Value = DateAdd(DateInterval.Year, 2, Me.dtpJoinDate.Value)
                Case Is <> "Ovation Voter", Is <> "Organizational Member", Is <> "Subscription only"
                    Me.dtpCancelDate.Value = DateAdd(DateInterval.Year, 1, Me.dtpJoinDate.Value)
            End Select
        End If

    End Sub

How would I fix this warning?

Question by:GabicusC
    LVL 69

    Expert Comment

    by:Éric Moreau
    Hi GabicusC,

    shouldn't you use SelectedValue ?


    Author Comment


    I switched to SelectValue but I am still getting the same warning.
    LVL 69

    Accepted Solution

    I remember now: .Text

    Author Comment

    That is it.  Thanks emoreau!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    Title # Comments Views Activity
    C# class property update 5 53
    VB.Net - How to update a database 4 32
    Help file 1 28
    Handling arrays 14 27
    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    Introduction When many people think of the WebBrowser ( control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    This video discusses moving either the default database or any database to a new volume.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now