Dim rainfall(11) As Integer lstInput.Items.Add("Monthly Rainfall Input") lstInput.Items.Add("----------------------") 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")) lstInput.Items.Add(rainfall(i) & " for " & Month(i)) Next ' 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
3 Replies - 483 Views - Last Post: 22 January 2014 - 09:26 AM
How to close the form when cancel and exit are clicked in inputbox
Posted 22 January 2014 - 09:07 AM
Is it possible to make cancel and exit to close the form when clicked even if rainfall as integer?
Replies To: How to close the form when cancel and exit are clicked in inputbox
Re: How to close the form when cancel and exit are clicked in inputbox
Posted 22 January 2014 - 09:26 AM
Oh, sorry I was thinking of a String, convert the integer to a string to trim it. You will need to do this anyway, because what if they just put a space, or they put letters in the Input Box? If you are doing calculations later on and the user input letters you will get a Type conversion error.
Page 1 of 1