基本上我必须设计一个水果游戏,随机水果将被生成,并且孩子必须猜测水果类型。如果孩子猜对了,他们会收到一条消息说恭喜,如果他们错了,他们会收到一条消息,说“再试一次”。问题与一些Visual Basic编程代码
我已经完成了编程,但是当我输入水果的名字时,我不知道错误的位置。因为即使它是正确的,它也会给出一个消息,说它是错误的。
我有程序代码,当水果是正确的,并与它的消息。
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Button1.Visible = True ' The tools that will need to be hide when the check button is cliked
Button2.Visible = False
PictureBox1.Visible = False
TextBox1.Visible = False
If Label1.Text = "1" And TextBox2.Text = "Banana" Then ' If both are true then the following result is true
PictureBox2.Image = My.Resources.Well_done 'my.resources.name 'The well_done picture that appears for the correct
PictureBox2.Visible = True '- answer and at the same time it has to be visble
Label2.Text = "Congrats! " & TextBox2.Text & "! Correct answer!" 'The msg which appears for the correct answer
Label2.Visible = True
Me.BackColor = Color.Yellow ' The background colour of the form
ElseIf Label1.Text = "2" And TextBox1.Text = "apple" Then 'Similary for apple banana and other fruits
PictureBox2.Image = My.Resources.Well_done
PictureBox2.Visible = True
Label2.Text = "Congrats " & TextBox2.Text & "! Correct answer!"
Label2.Visible = True
Me.BackColor = Color.Green
ElseIf Label1.Text = "3" And TextBox1.Text = "orange" Then
PictureBox2.Image = My.Resources.Well_done
PictureBox2.Visible = True
Label2.Text = "Congrats " & TextBox2.Text & "! Correct answer!"
Label2.Visible = True
Me.BackColor = Color.Orange
ElseIf Label1.Text = "4" And TextBox1.Text = "Strawberry" Then
PictureBox2.Image = My.Resources.Well_done
PictureBox2.Visible = True
Label2.Text = "Congrats " & TextBox2.Text & "! Correct answer!"
Label2.Visible = True
Me.BackColor = Color.IndianRed
ElseIf Label1.Text = "5" And TextBox1.Text = "Grapes" Then
PictureBox2.Image = My.Resources.Well_done
PictureBox2.Visible = True
Label2.Text = "Congrats " & TextBox2.Text & "! Correct answer!"
Label2.Visible = True
Me.BackColor = Color.Green
VB.NET与VBA不一样,它们与VBScript或VB6都不相同。你究竟使用哪一个?这些标签中只有一个可以是正确的。 (是的,我知道哪一个,你也应该:-)) –
另外,你的问题是什么? “我不知道该做什么”不是问题。 – Neolisk
让我澄清你正在显示一张带有标签(或标签)的图片,孩子必须在文本框中输入他/她的猜测?你在这里做什么? – Edper