Create Picture box or fill it ???

divoli

New member
Joined
Aug 11, 2009
Messages
3
Programming Experience
Beginner
Hi,

I am newbie in VB.net so maybe what I will ask is very simple.

I want to create an application in which when :
  • user clicks the button the first time a picture be shown on picturebox1
  • user clicks the button the second time a picture be shown on picturebox2
  • user clicks the button the third time both pictureboxes would be empty
  • user clicks the button the fourth time a picture be shown on picturebox1

So I thought to create this boxes (instead of filling them cause I do not know how to fill them dynamically).
How can I delete them dynamically when the user clicks the button the third time?
 
A bit rough example, but it should be enough to get an idea about how it works.

VB.NET:
    Private flag As Integer = 0
    Private Sub Button1_Click(ByVal sender As System.Object, _
                              ByVal e As System.EventArgs) Handles Button1.Click
        flag += 1
        If flag <= 4 Then
            Select Case flag
                Case 1
                    Me.PictureBox1.Image = Image.FromFile("imagepath")
                Case 2
                    Me.PictureBox2.Image = Image.FromFile("imagepath")
                Case 3
                    Me.PictureBox1.Image = Nothing
                    Me.PictureBox2.Image = Nothing
                Case 4
                    Me.PictureBox1.Image = Image.FromFile("imagepath")
            End Select
        Else
            'reset the flag and repeat the Case 1 action
        End If
    End Sub
 
Thanks for the reply.

But I would like to fill and empty the pictureboxes with a loop (for statement).
Is this possible?

Secondly can I delete the pictureboxes? ( I know how to create them but I do not know how to delete them)
 
Last edited:
Back
Top