1 Replies - 268 Views - Last Post: 22 January 2014 - 07:31 PM Rate Topic: -----

#1 akif13  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-December 12

How to display month beside the minimum and maximum values

Posted 22 January 2014 - 04:44 PM

How can I display month(i) beside the minimum or maximum values. Let's say minimum was 12 and it was month January. I want it to be display beside the value of min or max. Is there any other way I can close the form when user clicked cancel and exit in InputBox? I don't know how to do it if rainfall(11) as "integer"
        Dim Month = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
        Dim rainfall(11) As Integer
        Dim i_max, i_min As Integer

        lstInput.Items.Add("Monthly Rainfall Input")

        For i = 0 To 11

            ' Input rainfall for each month, require non-negative numbers,
            rainfall(i) = CInt(InputBox("Please enter the rainfall for " & Month(i), "Challenge 2 - Rainfall Statistics"))
            ' and display input on the form for the user to see

            lstInput.Items.Add(rainfall(i) & " for " & Month(i))
            total = total + rainfall(i)
            avg = total / 12


        i_min = LBound(rainfall)
        i_max = UBound(rainfall)

        max = rainfall(i_min)
        min = rainfall(i_min)
        For i = i_min + 1 To i_max
            If rainfall(i) > max Then
                max = rainfall(i)
            ElseIf rainfall(i) < min Then
                min = rainfall(i)
            End If
            dispmin = "The minimum monthly rainfall was (" & min & ")" & Month(i)
            dispmax = "The maximum monthly rainfall was(" & max & ")" & Month(i)

        ' If the user clicks the Cancel button or enters an
        ' empty string, leave this Click handler immediately.
        ' Exit if the user clicks the Cancel button
        'initialize variables to first month's (January's) rainfall
        'look at rest of monthly rainfall data and update stats
        'calculate results and display them - note that if more than one
        'month tied for the max or min, only the first month is named as
        'the max or min on the output.

Is This A Good Question/Topic? 0
  • +

Replies To: How to display month beside the minimum and maximum values

#2 astonecipher  Icon User is offline

  • Major DIC Head
  • member icon

Reputation: 271
  • View blog
  • Posts: 1,360
  • Joined: 03-December 12

Re: How to display month beside the minimum and maximum values

Posted 22 January 2014 - 07:31 PM

Your question(s) are not that clear. Are you receiving errors, first?

Are you asking to close the form if the user clicks the cancel button on the input where they are entering the rainfall data?

If so, use dialogResult to retrieve the button pressed.

Where are you trying to display the information together and what are you trying to display?

Month Inches
January 11

something like that in your listbox?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1