---
title: "Change two images in one picture box using a button (VB.NET)"  
description: "Change two images in one picture box using a button (VB.NET)"  
author: "Mark Devid"  
published: 2013-04-05  
updated: 2013-04-05  
canonical: https://www.mindstick.com/forum/714/change-two-images-in-one-picture-box-using-a-button-vb-dot-net  
category: "asp.net mvc"  
tags: ["asp.net mvc"]  
reading_time: 2 minutes  

---

# Change two images in one picture box using a button (VB.NET)

Hi Everyone!\
I've been [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to change the [image](https://www.mindstick.com/articles/23551/an-investigate-distinctive-seafood-restaurant-for-your-image-stamp-character) in a [picture box](https://www.mindstick.com/forum/23034/picture-box-with-3-partitions-and-partitions-should-be-controlled-with-numeric-updown). It works if I want to change it with one image, but I can't get it to change to the other image. It \
should alternate between the two [images](https://www.mindstick.com/interview/1067/what-is-the-php-predefined-variable-that-tells-the-what-type-of-images-that-php-support) when I [click](https://www.mindstick.com/articles/12423/social-login-magento-2-one-click-to-register-social) the button.\
Here is my code:\
[Private](https://www.mindstick.com/blog/11097/java-access-modifiers-the-public-and-the-private-modifiers) Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click\
Dim num As [Boolean](https://www.mindstick.com/forum/160332/how-does-the-boolean-function-work) If num = False Then PictureBox3.Image = My.Resources.Beep num = True Else PictureBox3.Image = My.Resources.Skateboard num = False\
End IfEnd Sub\
I've been trying to [figure](https://yourviews.mindstick.com/view/87536/what-are-ghosts-jobs-and-how-to-figure-out-them) out why it doesn't work for a long time, any help wouldbe appreciated.\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!

## Replies

### Reply by Vijay Shukla

Hi Mark!\
You can try as below\
Dim num As Boolean\
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click\
If num = False Then PictureBox3.Image = My.Resources.Beep num = True Else PictureBox3.Image = My.Resources.Skateboard num = FalseEnd If\
End Sub

### Reply by AVADHESH PATEL

Hi Mark!\
Use button_click event as below\
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click\
Dim Shared num As Boolean If num = False Then PictureBox3.Image = My.Resources.Beep num = True Else PictureBox3.Image = My.Resources.Skateboard num = False End IfEnd SubClass level option\
I hope it resolve your problem


---

Original Source: https://www.mindstick.com/forum/714/change-two-images-in-one-picture-box-using-a-button-vb-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
