Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


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

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.

 

 

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