[英]Change output of textbox based on button clicked Visual Basic
Hi everyone I am new to visual basic and am making my first program from a book I just bought and would like to change the output of my textbox based on the button I click for example if button1 is clicked I would like it to say "You selected cheese.". 大家好,我是Visual Basic的新手,正在用我刚买的书制作我的第一个程序,并且想根据单击的按钮来更改文本框的输出,例如,如果单击button1,我想说“您精选奶酪。” Here is my code.
这是我的代码。
Public Class Form1 公开课表格1
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
End Class 最终班
It's as simple as: 就像这样简单:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.