Results 1 to 2 of 2

Thread: Problem...

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2004
    Posts
    10

    Problem...

    I am making a program by creating a class. THe program is supposed to allow the user to enter up to 50 numbers and then average them using an AddNumber method to store the numbers in an array. This is what i have below. After i enter a number and hit record, the program terminates...


    Dim theirnumber(50) As statistics
    Dim lastnumberadded As Integer = 0

    Private Sub btnRecordNumber_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRecordNumber.Click
    Dim average As Double
    Dim theirnumber = New statistics
    theirnumber.TheirNumber = CDbl(txtNumber.Text)
    lastnumberadded += 1
    theirnumber(lastnumberadded) = theirnumber
    txtNumber.Clear()
    txtAverage.Text = (average)
    End Sub
    End Class

    Class statistics
    Private m_number As Double

    Public Property TheirNumber() As Double
    Get
    Return m_number
    End Get
    Set(ByVal Value As Double)
    m_number = Value
    End Set
    End Property

    Function CalcAverage() As String
    Dim average, lastnumberadded As Double
    average = (m_number) / lastnumberadded
    End Function
    End Class

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Problem...

    I have to admit, after looking this over, I have so many questions I don't know whether I have an answer, so I'll start with a simple question:

    Why do you have CalcAverage returning a string when the result appears to be a double (or some such).
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width