VB.NET Inputbox - How to identify when the Cancel Button is pressed?

前端 未结 12 1627
灰色年华
灰色年华 2021-01-03 22:26

I have a simple windows application that pops up an input box for users to enter in a date to do searches.

How do I identify if the user clicked on the Cancel butt

12条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-03 23:30

    Guys remember that you can use the try catch end event

    Dim Green as integer
    
    Try
        Green = InputBox("Please enter a value for green")
        Catch ex as Exception
            MsgBox("Green must be a valid integer!")
    End Try
    

提交回复
热议问题