|
-
May 24th, 2004, 12:03 PM
#1
Thread Starter
Hyperactive Member
sending in params when loading a form
Is this now possible with vb.net? I know that before, the only way was to use global vars.
Sorry if the answer is extremely noticable when using .net. I haven't used much of it.
Thanks
-
May 24th, 2004, 12:07 PM
#2
Fanatic Member
You can create overloaded constructors for your form to take any additional paramters that you want to provide,
-
May 24th, 2004, 03:32 PM
#3
Thread Starter
Hyperactive Member
could you give me an example, if it's not too hard?
vars:
strName, arrCustomers
-
May 24th, 2004, 06:22 PM
#4
Hyperactive Member
open up the "Windows Form Designer generated code" Region and put some parameters in the New procedure. then just pass whatever you want when you call the new method. Or if you want to be able to Send and recive variables use a procedure
-
May 24th, 2004, 11:39 PM
#5
Sometimes the IDE designer freaks out if there is no default constructor (one with no required parameters). So to get around this and make life easier just create a new constructor in the normal code where and make Me.New() the first thing it does. That will ensure that all of the controls and what not the you did at designtime still get created as normal.
VB Code:
'In normal code area
'local variable to hold the references
Private _myParam As String=String.Empty
Public Sub New(myParam As String)
Me.New()
'set local to the one passed in
Me._myParam=myParam
End Sub
'Then you can create the form like this
Dim f As New Form1("MyParamValue")
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|