Results 1 to 6 of 6

Thread: Open Multiple forms

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    200

    Open Multiple forms

    Hi All,

    I have a question regarding an application that I am working on. I want to create multiple datagrid/dataset based on the value that the user inputs into a numericUpDown control. I want to be able to store data in multiple datagrid based on the value that is entered into the NumericUpDown control.


    For example if the user enters the value 2 into the numericUpDown control I want the program to create two datagrid in separate forms (datagrid1 in one form and datagrid2 in second form).


    I am using VB.Net 2003.

    Any help on this would be greately apprecaited. thanks



    -Srig

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Open Multiple forms

    Do you know how to create and display one form? If so then you simply execute the same code more than once. How do you do the same thing more than once? You use a loop. How do you determine how many times to loop? From the Value property of the NUD.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    200

    Re: Open Multiple forms

    Here is what I have thus far:


    Code:
    'To create a form, and to display it I would do this:
    
    DIM myForm1 as NEW NAME
    
    myForm1.ShowDialog()



    Code:
    'Now to Create Multiple form based on the the value inside of NUD
    
    DIM I as Integer
    DIM FORM AS NEW Name
    
    
    For i = Value_Increment.Value to 10 Step Value_Increment.Value
    	myForm(i).showDialog  '<== it gives me an error in this line.  why?
    
    Next

    Can you tell me what I am missing here. I have followed what was recommended.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    200

    Re: Open Multiple forms

    the above code works but not the way I want it to work. It opens the same form twice. Instead, I want to open two different forms, each containing different datagrid.

  5. #5
    Hyperactive Member NPassero's Avatar
    Join Date
    May 2007
    Location
    NJ
    Posts
    272

    Re: Open Multiple forms

    myForm(i).showDialog is referring to an ARRAY called myForm -

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Open Multiple forms

    If that first code snippet is what you do to open one form then that second snippet is NOT executing that operation multiple times. If the code to open one form is X then to perform X the number of times specified in a NumericUpDown would be:
    vb.net Code:
    1. For i As Integer = 1 To CInt(myNumericUpDown.Value) Step 1
    2.     X
    3. Next i
    Your first code snippet is X.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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