大家好我是视觉基础的新手,我正在从我刚购买的书中制作我的第一个程序,并希望根据我点击的按钮更改文本框的输出,例如,如果点击了button1我想要它说“你选择了奶酪。”这是我的代码。
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
PictureBox1.Image = My.Resources.cheese
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
PictureBox1.Image = My.Resources.cookie
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
PictureBox1.Image = My.Resources.pretzel
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
PictureBox1.Image = My.Resources.peanut
End Sub
Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
结束班
答案 0 :(得分:1)
这很简单:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
PictureBox1.Image = My.Resources.cheese
TextBox1.Text = "You selected cheese."
End Sub