vb.net 使按钮单击更改图片框中的图片visual basic
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15282874/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Make a button click change a picture in the picture box visual basic
提问by Nikita Zomer
I have one picture box and multiple buttons on Visual Basic 2010 Express. I'm looking for an example code for putting a picture in the box when I click the button and it changing when I click another button.
我在 Visual Basic 2010 Express 上有一个图片框和多个按钮。我正在寻找一个示例代码,用于在单击按钮时将图片放入框中,并在单击另一个按钮时更改。
回答by Belial09
if you use VBA like you tagged your question (before edit)... then try this.
如果您像标记问题一样使用 VBA(编辑前)...然后试试这个。
Private Sub button1_Click()
picture1.Picture = "C:.jpg"
End Sub
Private Sub button2_Click()
picture1.Picture = "C:.jpg"
End Sub
if its vb.net (which i indicate because you said visual studio 2010 express) try this
如果它的 vb.net(我指出是因为你说的是 Visual Studio 2010 express)试试这个
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
PictureBox1.Image = Image.FromFile("C:.jpg")
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
PictureBox1.Image = Image.FromFile("C:.jpg")
End Sub
exception handling is up to you :)
异常处理取决于你:)