How to pass parameters to a form

Posted in: Forms and Grids
By dePoPo
Mar 6, 2009 - 12:03:59 PM

Passing parameters from one form to another can be done in varuous ways, one of the easyer and more reliable ways is to add class parameters to the form. This will enable you to pass any data type to the form, and will also work reliable if you use MDI and have multiple forms of the same type. Using class parameters will ensure that each form will have its own parameters passed back and forth without influencing eachother.


' Create a new form
' Doubleclick the new empty form to bring up the code window
' Add the parameters you want to the form in the top of the definition, example:
 
Public Class form_Attachments
 
Public n_formclass_pageid As integer ' this is a new added parameter
Public n_formclass_subgroupid As integer ' this is also a new added parameter
 
Private Sub form_Attachments_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
End Sub
 
End Class
 
 
 
' Example to open the form with parameters from anywhere in your code
 
Dim myform as New form_Attachments
myform.n_formclass_pageid=100
myform.n_formclass_subgroupid=9
myform.Show


Visitor Comments