Try again this one:
Protected Overrides Sub OnClosing(ByVal e As System.ComponentModel.CancelEventArgs)
dim res
res=msgbox("Do you want to close?",msgboxstyle.yesno,"sample")
if res=vbno then
e.cancel=false
else
e.cancel=true
endif
MyBase.OnClosing(e)
end sub
Put end sub after mybase.onclose(e) statement