I need to make one statement to select either of the items in listbox and show the same label, regardless of which item is selected. I've tried someting like

 If Me.ListBox1.SelectedItem = "R115" Or "Bay, Charles" Then
                Label1.Text = "Address Information Avaliable"
            End If

But it doesn't work. The code below works but I need to make it shorter.

If Me.ListBox1.SelectedItem = "R115" Or Me.ListBox1.SelectedItem = "Bay, Charles" Then
            Label1.Text = "Address Information Avaliable"
        End If

Any suggestions?

Recommended Answers

All 2 Replies

Why do you need to make it shorter? It works, it's simple and it's clear. What more do you want?

I was just wondering if there's other ways to code this, make it short in coding to make it less lines of code. But I guess if there isn't, I'll do it the way I have it right now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.