Page 1 of 1

Codebox plus

PostPosted: April 27th, 2013, 3:47 pm
by Jessica
[code=vb file=Untitled.txt]'Class describing the application
Public Class exploreForm

Private Sub calculateAverage(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles goBtn.Click
Dim total As Integer
Dim count As Integer
Dim calculatedAverage As Double

If IsNumeric(firstInputTB.Text) And IsNumeric(secondInputTB.Text) Then
total = CInt(firstInputTB.Text)
count = CInt(secondInputTB.Text)
If (count > 0) Then
calculatedAverage = total / count
output.AppendText(CStr(calculatedAverage) & vbCrLf)
Else
MessageBox.Show("Second value must be greater than 0")
End If
Else
output.AppendText("Enter numeric values only")

End If
End Sub
End Class[/code]