Results 1 to 5 of 5

Thread: sending in params when loading a form

  1. #1

    Thread Starter
    Hyperactive Member wordracr's Avatar
    Join Date
    Aug 2001
    Posts
    281

    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

  2. #2
    Fanatic Member
    Join Date
    May 2002
    Posts
    746
    You can create overloaded constructors for your form to take any additional paramters that you want to provide,

  3. #3

    Thread Starter
    Hyperactive Member wordracr's Avatar
    Join Date
    Aug 2001
    Posts
    281
    could you give me an example, if it's not too hard?
    vars:
    strName, arrCustomers

  4. #4
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409
    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

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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:
    1. 'In normal code area
    2.  
    3. 'local variable to hold the references
    4. Private _myParam As String=String.Empty
    5.  
    6.  
    7. Public Sub New(myParam As String)
    8.     Me.New()
    9.  
    10.     'set local to the one passed in
    11.     Me._myParam=myParam
    12. End Sub
    13.  
    14.  
    15. 'Then you can create the form like this
    16. 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
  •  



Click Here to Expand Forum to Full Width