3 Replies - 342 Views - Last Post: 22 January 2014 - 09:26 AM 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 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?
        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



Is This A Good Question/Topic? 0
  • +

Replies To: How to close the form when cancel and exit are clicked in inputbox

#2 ybadragon  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 193
  • View blog
  • Posts: 1,198
  • Joined: 11-May 12

Re: How to close the form when cancel and exit are clicked in inputbox

Posted 22 January 2014 - 09:16 AM

you would need and If statement that checks if rainfall(i).trim is empty. If it is then Application.Exit()
Was This Post Helpful? 0
  • +
  • -

#3 akif13  Icon User is offline

  • New D.I.C Head

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

Re: How to close the form when cancel and exit are clicked in inputbox

Posted 22 January 2014 - 09:24 AM

it showed "trim is not a member of integer"
Was This Post Helpful? 0
  • +
  • -

#4 ybadragon  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 193
  • View blog
  • Posts: 1,198
  • Joined: 11-May 12

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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1