We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

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

Richard Comito
on
Medium Priority
438 Views
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?

Thanks,
Comment
Watch Question

Éric MoreauSenior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016

Commented:
Hi GabicusC,

shouldn't you use SelectedValue ?

Cheers!
Richard ComitoDirector of IT

Author

Commented:
emoreau,

I switched to SelectValue but I am still getting the same warning.
Senior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016
Commented:
I remember now: .Text

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Richard ComitoDirector of IT

Author

Commented:
That is it.  Thanks emoreau!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.