Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 131,773 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,096 people online right now. Registration is fast and FREE... Join Now!




using stop button to end game

 
Reply to this topicStart new topic

using stop button to end game, need to code button for user to end game.

farah0288
post 10 Oct, 2008 - 02:34 PM
Post #1


New D.I.C Head

*
Joined: 10 Oct, 2008
Posts: 1

CODE


Option Explicit On
Option Strict On

Public Class MainForm

    Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
        Me.Close()

    End Sub

    Private Sub MainForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Fills the list box with items, then selects the first item

        guessListBox.Items.Add("")
        guessListBox.Items.Add("0")
        guessListBox.Items.Add("1")
        guessListBox.Items.Add("2")
        guessListBox.Items.Add("3")
        guessListBox.Items.Add("4")
        guessListBox.Items.Add("5")
        guessListBox.Items.Add("6")
        guessListBox.Items.Add("7")
        guessListBox.Items.Add("8")
        guessListBox.Items.Add("9")
        guessListBox.Items.Add("10")
        guessListBox.SelectedIndex = 0
    End Sub

    Private Sub submitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitButton.Click
        'Display a message indicating if the user guessed the correct number
        'times the user selects an incorrect number

        Dim randomGenerator As New Random
        Dim userChoice As String
        Dim computerChoice As Integer
        Static numberCorrect As Integer
        Static numberIncorrect As Integer
        computerChoice = 7

        'Saves the user's list box selection, then disables the list box
        userChoice = guessListBox.SelectedItem.ToString
        guessListBox.Enabled = True


        'Display correct and incorrect times a user guesses
        'Display appropriate message box
        If CDbl(userChoice) = computerChoice Then
            numberCorrect = numberCorrect + 1
            applePictureBox.SetBounds(0, 0, 0, 0)
            MessageBox.Show("Good Job!")
        ElseIf CDbl(userChoice) > computerChoice Then
            numberIncorrect = numberIncorrect + 1
            applePictureBox.SetBounds(0, 0, 0, 5)
            MessageBox.Show("Sorry, wrong answer.")
        ElseIf CDbl(userChoice) < computerChoice Then
            numberIncorrect = numberIncorrect + 1
            applePictureBox.SetBounds(0, 0, 0, -5)
            MessageBox.Show("Sorry, wrong answer.")
        End If
        correctLabel.Text = Convert.ToString(numberCorrect)
        incorrectLabel.Text = Convert.ToString(numberIncorrect)

    End Sub

    Private Sub stopButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles stopButton.Click

    End Sub
End Class


Mod edit - Added code tags.
User is offlineProfile CardPM

Go to the top of the page

BetaWar
post 10 Oct, 2008 - 03:25 PM
Post #2


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,980



Thanked 77 times

Dream Kudos: 1175
My Contributions


Moved to VB
User is online!Profile CardPM

Go to the top of the page

PsychoCoder
post 10 Oct, 2008 - 03:26 PM
Post #3


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,911



Thanked 116 times

Dream Kudos: 8450

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


Moved to VB.NET smile.gif
User is online!Profile CardPM

Go to the top of the page

Jayman
post 10 Oct, 2008 - 05:02 PM
Post #4


Student of Life

Group Icon
Joined: 26 Dec, 2005
Posts: 6,830



Thanked 38 times

Dream Kudos: 500

Expert In: C#, VB.NET, Java

My Contributions


Can you describe in detail the functionality of the button event that you need?
User is online!Profile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 02:07PM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month