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