CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2006
    Posts
    48

    [RESOLVED] Reuse form

    Hi. I am have developed a program that has a main form, Form1. Then from Form1, the user is allowed to click and access a second form know as Form 2 which is also known as ideas input form. If the user has ideas within ideas, then he can call again the Form2 and provide more ideas. However,
    when Form2 is loaded the first time, the user is allowed key in several ideas i.e. let say ideas 1, ideas 2, ideas 3 and so on. Then he felt that he has other ideas that is related to let say ideas 2 and he launched the same form, Form2 but he is keying in ideas 2.1, ideas 2.2, etc. (ideas related to ideas2). This can go on .. and on ..

    Form2 ---- Form2 -------- Form2------------> always Form2

    ideas 1
    ideas 2 --> ideas2.1
    ideas 2.2---> ideas2.2.1
    ideas2.2.2
    ideas 2.2.3
    ideas 3 --> ideas 3.1
    ideas 4 --> ideas 4.1
    ideas 4.2---> ideas4.2.1--->ideas4.2.1.1---> ideas4.2.1.1.1
    ideas 4.3

    It is going to be multilayered forms system using the same form.

  2. #2
    Join Date
    Sep 2006
    Posts
    635

    Re: Reuse form

    I think if this 'ideas' may put in treeview.

    see attachments
    Attached Images Attached Images  

  3. #3
    Join Date
    Nov 2006
    Posts
    48

    Re: Reuse form

    Thanks. But I do not need the treeview .. I need to reuse the same form and the form has textboxes, listboxes and comboboxes for filling.

  4. #4
    Join Date
    May 2005
    Location
    Sterling Heights, MI
    Posts
    74

    Re: Reuse form

    How about
    Code:
    Dim frm As Form
    
    Set frm = New Form2
    
    frm.Show

  5. #5
    Join Date
    Nov 2006
    Posts
    48

    Re: Reuse form

    Thanks Hack but your codes produce error. Please advise.

  6. #6
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Reuse form

    Quote Originally Posted by kwng
    Thanks Hack but your codes produce error. Please advise.
    How did you implement it ??

    personally i'd use a array of forms to handle this..

    Code:
    Public frm() As Form
    
    Temp = ubound(frm)+1
    Redim frm(Temp)
    Set frm(Temp) = New Form2
    
    frm(Temp).Show
    frm(Temp).Index = Temp ' Add this as a Public Variable to form 2
    For a full Working example havce a look at the IPchat App .. I use this method to open multiple Chat Forms (same base form) and use the index to keep track for closing and unloading...

    Gremmy.
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  7. #7
    Join Date
    Nov 2006
    Posts
    48

    Re: Reuse form

    Hi GremlinSA. Thank you very much for your code snippet. I have tried out it into trial and it still has error. I have compiled the codes and I hope you provide some pointers. Assumming I want to reuse form2 many times simultaneously and retain its value in the controls. As for your working example, error message saying "ntsvc.ocx is missing". I could not run your file. Your code looks very complicated .. need more time to decipher.
    Attached Files Attached Files
    Last edited by kwng; April 25th, 2007 at 02:18 PM.

  8. #8
    Join Date
    Nov 2006
    Posts
    48

    Re: [RESOLVED] Reuse form

    Thanks everyone for the help. I have resolved the problem using Hack codes in the right way.

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

Featured