RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 6, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Handling Erros In The Form_Load Routine

In VB3, the PostMessage API can cancel an error during Form_Load. The form unloads if you send a WM_CLOSE message to the loaded window in the error handler of the Form_Load routine. It is not easy to find out from the calling routine exactly why the form unloaded. In VB4, you can create a property on your form to indicate success or failure, and unload the form from the calling procedure depending upon the value of that property:
 Public SuccessfulLoad As Boolean 
' creates the property Form1.SuccessfulLoad

Private Sub Form_Load()
	SuccessfulLoad = True
	If An Error Occurs Then
	SuccessfulLoad = False
	End If
End Sub
In the calling procedure:
 Sub LoadTheFubarForm()
	Dim MyForm As Form1

	Set MyForm = New Form1
	Load MyForm
	If MyForm.SuccessfulLoad Then
		MyForm.Show vbModal
	End If
	Unload MyForm
	Set MyForm = Nothing
End Sub
A. Nicklas
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date