james_h
Member
- Joined
- Aug 21, 2012
- Messages
- 15
- Programming Experience
- Beginner
Hi Guys,
I am brand new to programming and I have been teaching myself VB 2010 for 2 weeks and would appreciate someone that knows what they are doing to have a look to see what they think of my efforts on this little project. It all seems to work with no problems, so I guess that is a good start. I am guessing there may be more efficient ways to achieve the end results maybe?
Not sure if this is the best way to go about this?
Here is the code for the project.
And a screen shot of the actual game
Thanks for having a look guys.
I am brand new to programming and I have been teaching myself VB 2010 for 2 weeks and would appreciate someone that knows what they are doing to have a look to see what they think of my efforts on this little project. It all seems to work with no problems, so I guess that is a good start. I am guessing there may be more efficient ways to achieve the end results maybe?
Not sure if this is the best way to go about this?
Here is the code for the project.
Public Class Form1 Dim wins As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load RadioButton2.Checked = True ComboBox1.Text = 1 Label2.Text = 0 End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim rnd As New Random PictureBox1.Location = New Point(rnd.Next(1, 250), rnd.Next(60, 250)) End Sub Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged If RadioButton1.Checked = True Then Label4.Visible = False If wins >= 10 Then PictureBox1.BackgroundImage = Image.FromFile("C:\Users\james\Documents\Visual Studio 2010\Icons\Bird-red.png") End If Timer1.Start() End If End Sub Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged If RadioButton2.Checked = True Then Timer1.Stop() PictureBox1.Location = New Point(165, 250) End If End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged If ComboBox1.Text = 1 Then Timer1.Interval = 1000 ElseIf ComboBox1.Text = 2 Then Timer1.Interval = 750 ElseIf ComboBox1.Text = 3 Then Timer1.Interval = 650 ElseIf ComboBox1.Text = 4 Then Timer1.Interval = 500 ElseIf ComboBox1.Text = 5 Then Timer1.Interval = 350 End If End Sub Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click Label2.Text = CInt(wins) If RadioButton1.Checked = True And Timer1.Interval = 1000 Then RadioButton2.Checked = True MessageBox.Show("Congrats!! You have won 1 coin!!") wins += 1 Label2.Text = wins ElseIf RadioButton1.Checked = True And Timer1.Interval = 750 Then RadioButton2.Checked = True MessageBox.Show("Congrats!! You have won 2 coins!!") wins += 2 Label2.Text = wins ElseIf RadioButton1.Checked = True And Timer1.Interval = 650 Then RadioButton2.Checked = True MessageBox.Show("Congrats!! You have won 3 coins!!") wins += 3 Label2.Text = wins ElseIf RadioButton1.Checked = True And Timer1.Interval = 500 Then RadioButton2.Checked = True MessageBox.Show("Congrats!! You have won 4 coins!!") wins += 4 Label2.Text = wins ElseIf RadioButton1.Checked = True And Timer1.Interval = 350 Then RadioButton2.Checked = True MessageBox.Show("Congrats!! You have won 5 coins!!") wins += 5 Label2.Text = wins Else MessageBox.Show("The Game isn't running! Start Game to Win!!!") End If End Sub End Class
And a screen shot of the actual game
Thanks for having a look guys.
Last edited by a moderator: