CType converts an object to a particular data type, but can only do so if the data types are compatible. So in the case of this:
Code:
Dim PB As PictureBox = CType(sender, PictureBox)
...it converts sender from whatever data type it currently is to a PictureBox. In your case it wont work, because sender is a button (which is not compatible for conversion to a picturebox).

Originally Posted by
kubau2
I want each of them to work using one code.
That isn't particularly clear... if you mean you want it to work with all of them at the 'same' time, you can do this:
Code:
For Each Ctl As Control In Me.Controls
If Ctl.Name Like "PictureBox*" Then
Dim PB As PictureBox = CType(Ctl, PictureBox)
'your Select Case etc here
End If
Next