I'm working on a program, in which on the click of the button a new PictureBox is declared. The problem is, that i'm checking if the PictureBox exists first, using the code
If picCanvas2 Is Nothing Then Dim picCanvas2 As New PictureBox AddHandler picCanvas2.MouseDown, AddressOf picCanvas2_MouseDown Else End If
And with the first line, i get an error saying that picCanvas2 isn't declared. Is there any other way to check if it exists without getting an undeclared error?