My program will not work

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 2309 Views - Last Post: 02 May 2012 - 05:19 PM Rate Topic: -----

#1 imckinn40  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 19-March 12

My program will not work

Posted 02 May 2012 - 03:23 AM

I have tried everything and now when I run the program not will it not allow me to input the score it won't let me exit the program. This is what I have:


' Program Name: Football Fever Scoreboard
' Author:       Iris Mckinney   
' Date:         April 25, 2012
' Purpose:      This application calculates the points
'               scored during a football game by one team.
Option Strict On

Public Class lblFootballFeverScoreboard

    ' The btnEnterScore event accepts and displays up to ten scores
    ' from the user, and then print last score.

    Private Sub btnEnterScore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnterScore.Click

        btnEnterScore.Enabled = False
        Dim strScore As String
        Dim intScore As Integer
        Dim intFinalScore As Integer = 0
        Dim strInputMessage As String = "Enter the score for game #"
        Dim strInputHeading As String = "Football Score"
        Dim strNormalMessage As String = "Enter the score for game #"
        Dim strNonNumericError As String = "Error - Enter a number for th score #"
        Dim strNegativeError As String = "Error please enter a positive number for score #"
        Dim Cnt As Integer

        Dim intTotalScore As Integer
        Dim strCancelClicked As String = ""
        Dim intMaxNumberOfEntries As Integer = 0
        Dim intNumberOfEntries As Integer = 0

        ' This loop allows the user to enter the Football Scores of up to
        ' 10 scores. The loop terminates when the user has entered 10
        ' scores.

        Do
            strScore = InputBox(strInputMessage & intNumberOfEntries + 1, strInputHeading, " ")

            If intScore = -10 Then
                Exit Do
            End If
            If IsNumeric(strScore) Then
                intFinalScore = CInt(strScore)
                If intScore > 0 Then
                    lstScoreboard.Items.Add(strScore)
                    intFinalScore += intScore
                    intNumberOfEntries += 1
                    Cnt += 1
                    strInputMessage = strNormalMessage
                End If

            End If

        Loop


        lblFinalScore.Visible = True

        If intNumberOfEntries > 1 Then
            intFinalScore = intTotalScore + intScore - 1
            lblFinalScore.Text = "Average score per game is " & _
                intFinalScore / Cnt
        Else
            lblFinalScore.Text = "no score entered"
        End If

        btnEnterScore.Enabled = False
    End Sub

    Private Sub mnuClearItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuClearItem.Click

        lstScoreboard.Items.Clear()
        lblFinalScore.Visible = False
        btnEnterScore.Enabled = True
    End Sub

    Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuExit.Click

        Close()
    End Sub
End Class



Is This A Good Question/Topic? 0
  • +

Replies To: My program will not work

#2 kojima100  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 66
  • Joined: 10-November 10

Re: My program will not work

Posted 02 May 2012 - 04:15 AM

intScore never changes from it initialised value of 0. so the loop never exits
Was This Post Helpful? 0
  • +
  • -

#3 imckinn40  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 19-March 12

Re: My program will not work

Posted 02 May 2012 - 04:21 AM

I had:
Loop Until intMaxNumberOfEntries = 10 or strScore = -10


This gave error so I changed it to intScore I had no error but it still didn't work and it wouldn't let me exit out at all.
Was This Post Helpful? 0
  • +
  • -

#4 kojima100  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 66
  • Joined: 10-November 10

Re: My program will not work

Posted 02 May 2012 - 05:54 AM

Try:

Loop Until intMaxNumberOfEntries = 10 or cInt(strScore) = -10


Was This Post Helpful? 1
  • +
  • -

#5 imckinn40  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 19-March 12

Re: My program will not work

Posted 02 May 2012 - 12:21 PM

That worked but now I have errors in the following:

strScore = Val(InputBox(strInputMessage & intNumberOfEntries + 1, strInputMessage, " "))
      If strScore = -10 Then
      If strScore > 0 Then
      decFinalScore += strScore

The whole first line read error, all the strScore read errors except for the last line, the error there is decFinalScore.
What I'm I doing wrong?
Was This Post Helpful? 0
  • +
  • -

#6 imckinn40  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 19-March 12

Re: My program will not work

Posted 02 May 2012 - 01:53 PM

This is what I have so far, I changed it.

' Program Name: Football Fever Scoreboard
' Author:       Iris McKinney
' Date:         April 25, 2012
' Purpose:      This application calculates the points
'               scored during a football game by one team

Option Strict On

Public Class frmFootballFeverScoreboard

    ' The btnEnterScore event accepts and displays up to ten scores 
    ' from the user, and then print last score.

    Private Sub btnEnterScore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnterScore.Click

        Dim strScore As String
        Dim decScore As Integer
        Dim decFinalScore As Integer = 0
        Dim strInputMessage As String = "Enter the score for game #"
        Dim strInputHeading As String = "Football Score"
        Dim strNormalMessage As String = "Enter the score for game #"
        Dim strNonNumericError As String = "Error - Enter a number for th score #"
        Dim strNegativeError As String = "Error please enter a positive number for score #"
        Dim Cnt As Integer
        Dim intTotalScore As Integer
        Dim strCancelClicked As String = ""
        Dim intMaxNumberOfEntries As Integer = 0
        Dim intNumberOfEntries As Integer = 0

        Do
            strScore = Val(InputBox(strInputMessage & intNumberOfEntries + 1, strInputHeading, " "))

            If strScore = -10 Then
                Exit Do
            End If
            If IsNumeric(strScore) Then
                decFinalScore = CInt(strScore)
                If strScore > 0 Then
                    lstScoreboard.Items.Add(strScore)
                    decFinalScore += strScore
                    intNumberOfEntries += 1
                    Cnt += 1
                    strInputMessage = strNormalMessage
                End If

            End If

        Loop Until intMaxNumberOfEntries = 10 Or CInt(strScore) = -10

        lblFinalScore.Visible = True

        If intNumberOfEntries > 1 Then
            'decFinalScore = intTotalScore + decScore - 1
            lblFinalScore.Text = "Average score per game is " & _
            decFinalScore / Cnt
        Else
            lblFinalScore.Text = "no score entered"
        End If

        btnEnterScore.Enabled = True
    End Sub

   
End Class

    

Was This Post Helpful? 0
  • +
  • -

#7 DimitriV  Icon User is online

  • >not activating your almonds
  • member icon

Reputation: 556
  • View blog
  • Posts: 2,660
  • Joined: 24-July 11

Re: My program will not work

Posted 02 May 2012 - 02:16 PM

So, what are the errors with this?
Was This Post Helpful? 0
  • +
  • -

#8 imckinn40  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 19-March 12

Re: My program will not work

Posted 02 May 2012 - 02:20 PM

I'm having problem with the following:

strScore = Val(InputBox(strInputMessage & intNumberOfEntries + 1, strInputMessage, " "))
2
      If strScore = -10 Then
3
      If strScore > 0 Then
4
      decFinalScore += strScore


The whole first line read errors, all the strScore read errors except for the last line, the error there is decFinalScore.
Was This Post Helpful? 0
  • +
  • -

#9 DimitriV  Icon User is online

  • >not activating your almonds
  • member icon

Reputation: 556
  • View blog
  • Posts: 2,660
  • Joined: 24-July 11

Re: My program will not work

Posted 02 May 2012 - 02:22 PM

Does it tell you what they are?
Was This Post Helpful? 0
  • +
  • -

#10 imckinn40  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 19-March 12

Re: My program will not work

Posted 02 May 2012 - 02:25 PM

This is what it reads for all


Error 1 Option Strict On disallows implicit conversions from 'Double' to 'String'. C:\Users\best buy\Documents\Visual Basic Class\McKinneyFootballFever\McKinneyFootballFever\frmFootball Fever.vb 31 24 McKinneyFootballFever


Error	1	Option Strict On disallows implicit conversions from 'Double' to 'String'.	C:\Users\best buy\Documents\Visual Basic Class\McKinneyFootballFever\McKinneyFootballFever\frmFootball Fever.vb	31	24	McKinneyFootballFever


Was This Post Helpful? 0
  • +
  • -

#11 DimitriV  Icon User is online

  • >not activating your almonds
  • member icon

Reputation: 556
  • View blog
  • Posts: 2,660
  • Joined: 24-July 11

Re: My program will not work

Posted 02 May 2012 - 02:32 PM

So you'll need to maybe use Double.Parse or Double.TryParse.
Was This Post Helpful? 1
  • +
  • -

#12 imckinn40  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 19-March 12

Re: My program will not work

Posted 02 May 2012 - 02:36 PM

I never used that where would I place it and do it go with the frist line of errors I showed or for the strScore or decFinalScore?
Was This Post Helpful? 0
  • +
  • -

#13 DimitriV  Icon User is online

  • >not activating your almonds
  • member icon

Reputation: 556
  • View blog
  • Posts: 2,660
  • Joined: 24-July 11

Re: My program will not work

Posted 02 May 2012 - 02:47 PM

Dim strScore as Double = Double.Parse(thing)
Was This Post Helpful? 1
  • +
  • -

#14 imckinn40  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 19-March 12

Re: My program will not work

Posted 02 May 2012 - 03:21 PM

Do I need to replace anything or just add it to the program.
Was This Post Helpful? 0
  • +
  • -

#15 DimitriV  Icon User is online

  • >not activating your almonds
  • member icon

Reputation: 556
  • View blog
  • Posts: 2,660
  • Joined: 24-July 11

Re: My program will not work

Posted 02 May 2012 - 03:33 PM

Replace first line!
Dim strScore As Double = Double.Parse(InputBox(strInputMessage & intNumberOfEntries + 1, strInputMessage, " ")) 

Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2