Hey all, got a syntax and run prob with a program I'm working with that takes in rainfall amounts and then shows the total rainfall amount and then gives an average of. I then end up displaying those figures for the user.

as you can see below in the CalcTotalAndAverage and xCalcButton parts...I'm kinda hitting a wall. and help, hints?

Option Explicit On
Option Strict On

Public Class MainForm

    Private Sub CalcTotalAndAverage(ByVal rainCounter As Integer, _
                                    ByVal rainAccum As Decimal, _
                                    ByVal avgRain As Decimal)

        rainAccum = rainCounter
        avgRain = (rainAccum / rainCounter)




    End Sub

    Private Sub xExitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xExitButton.Click
        Me.Close()
    End Sub

    Private Sub xCalcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xCalcButton.Click
        ' calls a procedure to calculate the total and average
        ' rainfall amounts, then displays both amounts

        Static rainCounter As Integer
        Static rainAccum As Decimal
        Dim avgRain As Decimal

        Call CalcTotalAndAverage(rainCounter, rainAccum, avgRain)

        Me.xTotalLabel.Text = rainAccum.ToString("N2")
        Me.xAverageLabel.Text = avgRain.ToString("N2")

        Me.xMonthlyTextBox.Focus()
        Me.xMonthlyTextBox.SelectAll()
    End Sub

    Private Sub xMonthlyTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles xMonthlyTextBox.Enter
        Me.xMonthlyTextBox.SelectAll()
    End Sub

    Private Sub xMonthlyTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles xMonthlyTextBox.KeyPress
        ' accept numbers, the period, and the Backspace

        If (e.KeyChar < "0" OrElse e.KeyChar > "9") _
            AndAlso e.KeyChar <> "." AndAlso e.KeyChar <> ControlChars.Back Then
            e.Handled = True
        End If
    End Sub

    Private Sub xMonthlyTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles xMonthlyTextBox.TextChanged
        Me.xTotalLabel.Text = String.Empty
        Me.xAverageLabel.Text = String.Empty
    End Sub
End Class

so what the problem friend :) any error occurred?

any error occurred?

not really an error but just nothing. the application locks up and then i have to restart it

i confused when i read your code?
what exactly you want to do?

Private Sub xCalcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xCalcButton.Click
' calls a procedure to calculate the total and average
' rainfall amounts, then displays both amounts

Static rainCounter As Integer
Static rainAccum As Decimal
Dim avgRain As Decimal

Call CalcTotalAndAverage(rainCounter, rainAccum, avgRain)

Me.xTotalLabel.Text = rainAccum.ToString("N2")
Me.xAverageLabel.Text = avgRain.ToString("N2")

Me.xMonthlyTextBox.Focus()
Me.xMonthlyTextBox.SelectAll()
End Sub

see your part code above.
- you call CalcTotalAndAverage but you don't have a value for rainCounter and rainAccum.

- your procedure parameter is wrong.

Private Sub CalcTotalAndAverage(ByVal rainCounter As Integer, _
ByVal rainAccum As Decimal, _
ByVal avgRain As Decimal)
rainAccum = rainCounter
avgRain = (rainAccum / rainCounter)
End Sub

avgRain is not input but a result of dividing.. so you cannot set it as input. declare this variable inside of procedure.
it must be :

Private Sub CalcTotalAndAverage(ByVal rainCounter As Integer,                                     ByVal rainAccum As Decimal)
        [B]Dim ByVal avgRain As Decimal[/B]
        rainAccum = rainCounter
        avgRain = (rainAccum / rainCounter)
    End Sub

Actually i don't understand your program. please explain more detail what you want to do.

Actually i don't understand your program. please explain more detail what you want to do.

well i'll take the statement straight from the book.

"In this exercise, you create an application that allows the user to enter any number of monthly rainfall amounts. the application should calculate and display the total rainfall amount and the average rainfall amount.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.