Public Class Form1
Dim strMonths() As String = {"January", "February", "March", "April", _
"May", "June", "July", "August", "September", "October", "November", _
"December"}
Dim intMonths(11) As Integer
Dim intRain() As Integer
Private Sub btnMonthlyRental_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMonthlyRainfall.Click
Dim intcount As Integer
Dim intRain As Integer
lstInput.Items.Add("Monthly Rainfall Input")
lstInput.Items.Add("----------------------")
For intcount = 0 To 12
Next
intValidationerrors = 0
Dim strTemp As String = InputBox("Enter the amount of rainfall in inches for " & strMonths(intcount))
If Not IsNumeric(strTemp) Then
MessageBox.Show("Value must be a number", "Error")
intValidationerrors = 1
Else
decRain = CDec(strTemp)
If decRain < 0 Then
MessageBox.Show("Value cannot be a negative number", "Error")
intValidationerrors = 1
End If
End If
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstInput.SelectedIndexChanged
End Sub
Private Sub btnDisplayStats_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplayStats.Click
End Sub
Public Function FindLargest() As Integer
Dim intCount As Integer
Dim intMax As Integer = intMonths(0)
For intCount = 1 To (intMonths.Length - 1)
If intMonths(intcount) > intMax Then
intMax = intMonths(intCount)
End If
Next intCount
lblMaxium.Text = "THe maximum monthly rainfall was " & intMax.ToString
Return intMax
End Function
Public Function FindSmallest() As Integer
Dim intCount As Integer
Dim intMin As Integer = intMonths(0)
For intCount = 1 To (intMonths.Length - 1)
If intMonths(intCount) < intMin Then
intMin = intMonths(intCount)
End If
Next intCount
lblMinimum.Text = "The minimum monthly rainfall was " & intMin
Return intMin
End Function
Public Function TotalRainFall() As Integer
'Calculate Total
Dim intCount As Integer
Dim intTotal As Integer = 0
For intCount = 0 To (strMonths.Length - 1)
intTotal += intMonths(intCount)
Next intCount
lblTotal.Text = "The total annual rainfall was "
Return intTotal
End Function
Public Function Average() As Integer
Dim intCount As Integer
Dim intTotal As Integer = 0
Dim intAverage As Integer
For intCount = 0 To (strMonths.Length - 1)
intTotal += intMonths(intCount)
intAverage = CInt(intTotal / 12)
Next intCount
lblAverage.Text = "The average monthly rainfall was " & intAverage.ToString("d")
Return intAverage
End Function
Private Sub lblTotal_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblTotal.TextChanged
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Im Having a problem with Rainfall Stats VB
Page 1 of 11 Replies - 886 Views - Last Post: 04 May 2012 - 02:21 PM
#1
Im Having a problem with Rainfall Stats VB
Posted 04 May 2012 - 01:50 PM
[Im having a very tough time with this assignment for VB ive went to many sites and still cant find how to make this program work .Can anyone provide me in some answers heres what i have so far but it keep saying i have syntax errors and i cant display my stats
Replies To: Im Having a problem with Rainfall Stats VB
#2
Re: Im Having a problem with Rainfall Stats VB
Posted 04 May 2012 - 02:21 PM
We will help you. But first, some pointers:
•This is not a VB forum. You should get a mod to move it.
•Please, when posting problem code, highlight the issues not merely mention "I have syntax errors".
For example, the For loop at the top of the code (0 To 12) has no code in it and is therefore either being not utilized properly or is obsolete. The code after that up until the End Sub should be inside that loop's body.
•This is not a VB forum. You should get a mod to move it.
•Please, when posting problem code, highlight the issues not merely mention "I have syntax errors".
For example, the For loop at the top of the code (0 To 12) has no code in it and is therefore either being not utilized properly or is obsolete. The code after that up until the End Sub should be inside that loop's body.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|