Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 422
  • Last Modified:

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

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?

Richard Comito
Richard Comito
  • 2
  • 2
1 Solution
Éric MoreauSenior .Net ConsultantCommented:
Hi GabicusC,

shouldn't you use SelectedValue ?

Richard ComitoDirector of ITAuthor Commented:

I switched to SelectValue but I am still getting the same warning.
Éric MoreauSenior .Net ConsultantCommented:
I remember now: .Text
Richard ComitoDirector of ITAuthor Commented:
That is it.  Thanks emoreau!

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now