基本上我必须设计一个水果游戏,其中会随机生成一个水果,孩子必须猜测水果的类型。如果孩子猜对了,他们会收到一条消息说恭喜,如果他们猜错了,他们会收到一条消息说“再试一次”。
我已经完成了编程,但是当我输入水果的名称时,我不知道哪里出错了。因为即使它是正确的,它也会发出一条信息说它是错误的。
我有当水果正确时的程序代码和带有它的信息。
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