Re: VB.DOT NET Maths Question

  • From: "Marvin Hunkin" <startrekcafe@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sun, 28 Sep 2008 23:50:11 +1000

Hi.
here's the entire class for this project.
and i might have to put the variables on each line, was trying to combine 
the dec variables, and did not seem to like that.
so that might be part of the problem.
okay, here's it is.
cheers Marvin.

'Project: Chapter 5 Bowling Example
'Programmer: Bradley/Millspaugh
'Date: June 2005
'Folder: Ch05Bowling
'Description: This project calculates bowling statistics using


Public Class frmBowling


PrivateFunction FindAverage(ByVal ScoreOneInteger As Integer, _
ByVal ScoreTwoInteger as integer, ByVal ScoreThreInteger as Integer) As 
Decimal
    ' Return the average of three games.
return(ScoreOneInteger + ScoreTwoInteger + ScoreThreeInteger)
End Function
    Private Function FindHandicap(ByVal averageDecimal As Decimal) As 
Decimal
        ' Calculate the handicap.
Return (200D - averageDecimal) * 0.8D
    End Function
    Private Function FindSeries(ByVal game1Integer As Integer, _
    ByVal game2Integer As Integer, ByVal game3Integer As Integer) As Integer
        ' Calculate the series total.
        Return game1Integer + game2Integer + game3Integer
    End Function
    Private Function FindHighGame(ByVal game1Integer As Integer, _
    ByVal game2Integer As Integer, ByVal game3Integer As Integer) As String
        ' Find the highest game in the series.
        If game1Integer > game2Integer And game1Integer > game3Integer Then
            Return "1"
        ElseIf game2Integer > game1Integer And game2Integer > game3Integer 
Then
            Return "2"
        ElseIf game3Integer > game1Integer And game3Integer > game2Integer 
Then
            Return "3"
        Else
            Return "Tie"
        End If
    End Function











    Private Sub CalculateToolStripMenuItem_Click(ByVal sender As Object, 
ByVal e As System.EventArgs) Handles CalculateToolStripMenuItem.Click


        ' Calculate individual and summary info.

        Dim decAverage Handicap As Decimal
        Dim intSeries, GameOne, GameTwo, GameThree As Integer
        Dim strHighGame, Name As String

        Try
            With Me
                strName = Integer.Parse(tbNameTextBox.Text)
                intGameOne = Integer.Parse(tbGameOneTextBox.Text)
                intGameTwo = Integer.Parse(tbGameTwoTextBox.Text)
                intGameThree = Integer.Parse(tbGameThreeTextBox.Text)


                ' Perform all calculations.

                decAverage = FindAverage(GameOneInteger, GameTwoInteger, 
GameThreeInteger)
                intSeries = FindSeries(GameOneInteger, GameTwoInteger, 
GameThreeInteger)
                strHighGame = FindHighGame(GameOneInteger, GameTwoInteger, 
GameThreeInteger)
                decHandicap = FindHandicap(decAverage)

                ' Format the output.

                .tbNameTextBox.Text = strName.ToString()
                .tbGameOneTextBox.Text = intGameOne.ToString("N1")
                .tbGameTwoTextBox.Text = intGaneTwo.tostring("N1")
                .tbGameThreeTextBox.Text = intGameThree.ToString("N1")
                .tbAverageTextBox.Text = decAverage.ToString("N1")
                .tbHighGameTextBox.Text = strHighGame()
                .tbSeriesTextbox.Text = intSeries.ToString()
                .tbHandicapTextBox.Text = decHandicap.ToString("N1")








            End With
        Catch ex As Exception
            MessageBox.Show("Please Enter three numeric scores", "Missing 
Data", _
            MessageBoxButtons.OK)


        End Try





    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e 
As System.EventArgs) Handles ExitToolStripMenuItem.Click


        'Terminate the project.

        Me.Close()

    End Sub

    Private Sub chkMaleCheckBox_CheckedChanged(ByVal sender As Object, ByVal 
e As System.EventArgs) Handles chkMaleCheckBox.CheckedChanged


        'Set Visibility.


        chkMaleCheckBox.Checked = True


    End Sub

    Private Sub ClearToolStripMenuItem_Click(ByVal sender As Object, ByVal e 
As System.EventArgs) Handles ClearToolStripMenuItem.Click



        With Me
            With .NameTextBox
                .clear()
                .focus()
                .chkMaleCheckBox.checked = False
                .chkFemaleCheckBox.checked = False
                .tbGameOneTextbox.clear()
                .tbGameTwoTextBox.clear()
                .tbGameThreeTextBox.clear()
                .tbAverageTextBox.clear()
                .tbHandicapTextBox.clear()
                .tbSeriesTextBox.clear()
                .tbHighGameTextBox.clear()




            End With
        End With
    End Sub
End Class

----- Original Message ----- 
From: "Ricks Place" <OFBGMail@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Sunday, September 28, 2008 11:32 PM
Subject: Re: VB.DOT NET Maths Question


So here's the error window.
Error 1 Declaration expected.

C:\DOCS\Tafe\CertificateFourProgramming\CertFour\Programming\VisualBasic\
Book\VisualBasicProgramming\
ChapterFive\Example\
Bowling\Bowling\
frmBowling.vb
11 1 Bowling
Above tells you the problem is in line 11 in the  first character of the
statement. It just means something is wrong with the statement and it can
not figure out exactly what it is but something is wrong with it.
Error 2 Statement cannot appear outside of a method body.
The rest of these messages might be because they are not inside a valid
Function or Subroutine because the Function or Subroutine statement is
incorrect.
You can, when in the error window, left mouse click on an error and you
should be placed in the editor on the offending line.
Send me the code for the entire class so I can take another look at the
overall code.
Rick USA

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: