in form it have 2 listbox and in listbox1 and listbox2 items have "s1" , "s2" "s3"

Select Case ListBox1.Text And listBox2.Text

            Case "s1"
          p1.visible=tre 

            Case "s2"
          p2.visible=tre 

            Case "s3"
          p3.visible=tre 

        End Select

i want that the code check it item in listbox1 or 2 then do the same action
i tried

Select Case ListBox1.Text Or listBox2.Text
Select Case ListBox1.Text & listBox2.Text

but not work
i want the code do the same thing when u select "s1" item for etc in listbox 1 or listbox 2


thanks for help

please can you rephrase your question :( so that i can better help you .
but you can use for loop , for this .but after understanding your issue then i can better answer you.

Regards

You can use databiding from List<T> to listBox, and then check if items are in lists while looping through listBox:

Public Partial Class Form1
	Inherits Form
	Private list1 As List(Of String)
	Private list2 As List(Of String)
	Public Sub New()
		InitializeComponent()

		list1 = New List(Of String)() From { _
			"a", _
			"b", _
			"c", _
			"d" _
		}
		list2 = New List(Of String)() From { _
			"a", _
			"c", _
			"e", _
			"f" _
		}
		listBox1.DataSource = New BindingSource(list1, Nothing)
		listBox2.DataSource = New BindingSource(list2, Nothing)
	End Sub

	Private Sub button1_Click(sender As Object, e As EventArgs)
		For i As Integer = 0 To list1.Count - 1
			If list2.Contains(list1(i)) Then
				MessageBox.Show("Item " + list1(i) & " exists in both listBoxes.")
			End If
		Next
	End Sub
End Class
commented: Cool. I did not know you could do that. +9

form2 have 2 listboxs
like this
http://www.up.vatandownload.com/images/2ky9fdkve7313ueuqs6.jpg
as u can see 2 listboxs has the same items , i want when you click each one etc u select "s1" in listbox1 or listbox2 its do the same thing
i can put the whole code in ListBox2_SelectedIndexChanged event
but when u have lots of item it will be so crowded

Private Sub ListBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        Select Case ListBox1.Text or listbox2.text
            Case "s1"
                PictureBox1.Image = System.Drawing.Image.FromFile("c:\1.jpg")
            Case "s2"
                PictureBox1.Image = System.Drawing.Image.FromFile("c:\2.jpg")
            Case "s3"
                PictureBox1.Image = System.Drawing.Image.FromFile("c:\3.jpg")
        End Select
    End Sub
Be a part of the DaniWeb community

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