Sometimes, while creating controls, either by Inherited Controls or UserControls, we will be required to skip a piece of code depending upon the design time or runtime mode. This can be done easily by the following code inside a control.
If Me.Site IsNot Nothing AndAlso Me.Site.DesignMode = True Then 'Designtime code here Else 'Runtime code here End If
Using this code in a control, we can find the mode and avoid certain errors when in Design Mode. This is mostly used in overridden event methods in Inherited Controls.
![[VB.NET] Finding whether its Design Mode or Runtime Mode for Forms](https://www.jeygeethan.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBjUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--83e9b1eefb2dbf28cf8ba95e611a9763be3b888b/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBTU0lKYW5CbFp3WTZCa1ZVT2hKeVpYTnBlbVZmZEc5ZlptbDBXd2RwQWlBRGFRSWdBdz09IiwiZXhwIjpudWxsLCJwdXIiOiJ2YXJpYXRpb24ifX0=--6537b47e9694a3a864616c0c841b2b90918ae094/DesignTime.jpeg)


